Mage_Checkout_Block_Cart_Item_Renderer Class Reference

Inheritance diagram for Mage_Checkout_Block_Cart_Item_Renderer:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Bundle_Block_Checkout_Cart_Item_Renderer Mage_Checkout_Block_Cart_Item_Renderer_Configurable Mage_Checkout_Block_Cart_Item_Renderer_Grouped Mage_Downloadable_Block_Checkout_Cart_Item_Renderer

List of all members.

Public Member Functions

 setItem (Mage_Sales_Model_Quote_Item_Abstract $item)
 getItem ()
 getProduct ()
 overrideProductThumbnail ($productThumbnail)
 getProductThumbnail ()
 overrideProductUrl ($productUrl)
 getProductUrl ()
 getProductName ()
 getProductOptions ()
 getOptionList ()
 getDeleteUrl ()
 getQty ()
 getIsInStock ()
 getMessages ()
 getFormatedOptionValue ($optionValue)

Protected Attributes

 $_item
 $_productUrl = null
 $_productThumbnail = null


Detailed Description

Definition at line 34 of file Renderer.php.


Member Function Documentation

getDeleteUrl (  ) 

Get item delete url

Returns:
string

Definition at line 171 of file Renderer.php.

00172     {
00173         return $this->getUrl(
00174             'checkout/cart/delete',
00175             array(
00176                 'id'=>$this->getItem()->getId(),
00177                 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->helper('core/url')->getEncodedUrl()
00178             )
00179         );
00180     }

getFormatedOptionValue ( optionValue  ) 

Accept option value and return its formatted view

Parameters:
mixed $optionValue Method works well with these $optionValue format: 1. String 2. Indexed array e.g. array(val1, val2, ...) 3. Associative array, containing additional option info, including option value, e.g. array ( [label] => ..., [value] => ..., [print_value] => ..., [option_id] => ..., [option_type] => ..., [custom_view] =>..., )
Returns:
array

Definition at line 250 of file Renderer.php.

00251     {
00252         $optionInfo = array();
00253 
00254         // define input data format
00255         if (is_array($optionValue)) {
00256             if (isset($optionValue['option_id'])) {
00257                 $optionInfo = $optionValue;
00258                 if (isset($optionInfo['value'])) {
00259                     $optionValue = $optionInfo['value'];
00260                 }
00261             } elseif (isset($optionValue['value'])) {
00262                 $optionValue = $optionValue['value'];
00263             }
00264         }
00265 
00266         // render customized option view
00267         if (isset($optionInfo['custom_view']) && $optionInfo['custom_view']) {
00268             $_default = array('value' => $optionValue);
00269             if (isset($optionInfo['option_type'])) {
00270                 try {
00271                     $group = Mage::getModel('catalog/product_option')->groupFactory($optionInfo['option_type']);
00272                     return array('value' => $group->getCustomizedView($optionInfo));
00273                 } catch (Exception $e) {
00274                     return $_default;
00275                 }
00276             }
00277             return $_default;
00278         }
00279 
00280         // truncate standard view
00281         $result = array();
00282         if (is_array($optionValue)) {
00283             $_truncatedValue = implode("\n", $optionValue);
00284             $_truncatedValue = nl2br($_truncatedValue);
00285             return array('value' => $_truncatedValue);
00286         } else {
00287             $_truncatedValue = Mage::helper('core/string')->truncate($optionValue, 55, '');
00288             $_truncatedValue = nl2br($_truncatedValue);
00289         }
00290 
00291         $result = array('value' => $_truncatedValue);
00292 
00293         if (Mage::helper('core/string')->strlen($optionValue) > 55) {
00294             $result['value'] = $result['value'] . ' <a href="#" class="dots" onclick="return false">...</a>';
00295             $optionValue = nl2br($optionValue);
00296             $result = array_merge($result, array('full_view' => $optionValue));
00297         }
00298 
00299         return $result;
00300     }

getIsInStock (  ) 

Check item is in stock

Returns:
bool

Definition at line 197 of file Renderer.php.

00198     {
00199         if ($this->getItem()->getProduct()->isSaleable()) {
00200             if ($this->getItem()->getProduct()->getQty()>=$this->getItem()->getQty()) {
00201                 return true;
00202             }
00203         }
00204         return false;
00205     }

getItem (  ) 

Get quote item

Returns:
Mage_Sales_Model_Quote_Item

Definition at line 57 of file Renderer.php.

00058     {
00059         return $this->_item;
00060     }

getMessages (  ) 

Retrieve item messages Return array with keys

type => type of a message text => the message text

Returns:
array

Definition at line 216 of file Renderer.php.

00217     {
00218         $messages = array();
00219         if ($this->getItem()->getMessage(false)) {
00220             foreach ($this->getItem()->getMessage(false) as $message) {
00221                 $messages[] = array(
00222                     'text'  => $message,
00223                     'type'  => $this->getItem()->getHasError() ? 'error' : 'notice'
00224                 );
00225             }
00226         }
00227         return array_unique($messages);
00228     }

getOptionList (  ) 

Get list of all otions for product

Returns:
array

Reimplemented in Mage_Bundle_Block_Checkout_Cart_Item_Renderer, and Mage_Checkout_Block_Cart_Item_Renderer_Configurable.

Definition at line 161 of file Renderer.php.

00162     {
00163         return $this->getProductOptions();
00164     }

getProduct (  ) 

Get item product

Returns:
Mage_Catalog_Model_Product

Definition at line 67 of file Renderer.php.

00068     {
00069         return $this->getItem()->getProduct();
00070     }

getProductName (  ) 

Get item product name

Returns:
string

Reimplemented in Mage_Checkout_Block_Cart_Item_Renderer_Configurable.

Definition at line 115 of file Renderer.php.

00116     {
00117         return $this->getProduct()->getName();
00118     }

getProductOptions (  ) 

Get product customize options

Returns:
array || false

Definition at line 125 of file Renderer.php.

00126     {
00127         $options = array();
00128         if ($optionIds = $this->getItem()->getOptionByCode('option_ids')) {
00129             $options = array();
00130             foreach (explode(',', $optionIds->getValue()) as $optionId) {
00131                 if ($option = $this->getProduct()->getOptionById($optionId)) {
00132 
00133                     $quoteItemOption = $this->getItem()->getOptionByCode('option_' . $option->getId());
00134 
00135                     $group = $option->groupFactory($option->getType())
00136                         ->setOption($option)
00137                         ->setQuoteItemOption($quoteItemOption);
00138 
00139                     $options[] = array(
00140                         'label' => $option->getTitle(),
00141                         'value' => $group->getFormattedOptionValue($quoteItemOption->getValue()),
00142                         'print_value' => $group->getPrintableOptionValue($quoteItemOption->getValue()),
00143                         'option_id' => $option->getId(),
00144                         'option_type' => $option->getType(),
00145                         'custom_view' => $group->isCustomizedView()
00146                     );
00147                 }
00148             }
00149         }
00150         if ($addOptions = $this->getItem()->getOptionByCode('additional_options')) {
00151             $options = array_merge($options, unserialize($addOptions->getValue()));
00152         }
00153         return $options;
00154     }

getProductThumbnail (  ) 

Get product thumbnail image

Returns:
Mage_Catalog_Model_Product_Image

Reimplemented in Mage_Checkout_Block_Cart_Item_Renderer_Configurable, and Mage_Checkout_Block_Cart_Item_Renderer_Grouped.

Definition at line 83 of file Renderer.php.

00084     {
00085         if (!is_null($this->_productThumbnail)) {
00086             return $this->_productThumbnail;
00087         }
00088         return $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail');
00089     }

getProductUrl (  ) 

Get url to item product

Returns:
string

Reimplemented in Mage_Checkout_Block_Cart_Item_Renderer_Configurable, and Mage_Checkout_Block_Cart_Item_Renderer_Grouped.

Definition at line 102 of file Renderer.php.

00103     {
00104         if (!is_null($this->_productUrl)) {
00105             return $this->_productUrl;
00106         }
00107         return $this->getProduct()->getProductUrl();
00108     }

getQty (  ) 

Get quote item qty

Returns:
mixed

Definition at line 187 of file Renderer.php.

00188     {
00189         return $this->getItem()->getQty()*1;
00190     }

overrideProductThumbnail ( productThumbnail  ) 

Definition at line 72 of file Renderer.php.

00073     {
00074         $this->_productThumbnail = $productThumbnail;
00075         return $this;
00076     }

overrideProductUrl ( productUrl  ) 

Definition at line 91 of file Renderer.php.

00092     {
00093         $this->_productUrl = $productUrl;
00094         return $this;
00095     }

setItem ( Mage_Sales_Model_Quote_Item_Abstract item  ) 

Set item for render

Parameters:
Mage_Sales_Model_Quote_Item $item
Returns:
Mage_Checkout_Block_Cart_Item_Renderer

Definition at line 46 of file Renderer.php.

00047     {
00048         $this->_item = $item;
00049         return $this;
00050     }


Member Data Documentation

$_item [protected]

Definition at line 36 of file Renderer.php.

$_productThumbnail = null [protected]

Definition at line 38 of file Renderer.php.

$_productUrl = null [protected]

Definition at line 37 of file Renderer.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:49 2009 for Magento by  doxygen 1.5.8