Mage_Catalog_Block_Product_List_Upsell Class Reference

Inheritance diagram for Mage_Catalog_Block_Product_List_Upsell:

Mage_Catalog_Block_Product_Abstract Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getItemCollection ()
 getItems ()
 getRowCount ()
 setColumnCount ($columns)
 getColumnCount ()
 resetItemsIterator ()
 getIterableItem ()
 setItemLimit ($type, $limit)
 getItemLimit ($type= '')

Protected Member Functions

 _prepareData ()
 _beforeToHtml ()

Protected Attributes

 $_columnCount = 4
 $_items
 $_itemCollection
 $_itemLimits = array()


Detailed Description

Definition at line 35 of file Upsell.php.


Member Function Documentation

_beforeToHtml (  )  [protected]

Before rendering html, but after trying to load cache

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 83 of file Upsell.php.

00084     {
00085         $this->_prepareData();
00086         return parent::_beforeToHtml();
00087     }

_prepareData (  )  [protected]

Updating collection with desired items

Definition at line 45 of file Upsell.php.

00046     {
00047         $product = Mage::registry('product');
00048         /* @var $product Mage_Catalog_Model_Product */
00049         $this->_itemCollection = $product->getUpSellProductCollection()
00050             ->addAttributeToSort('position', 'asc')
00051             ->addStoreFilter()
00052         ;
00053         Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
00054             Mage::getSingleton('checkout/session')->getQuoteId()
00055         );
00056         $this->_addProductAttributesAndPrices($this->_itemCollection);
00057 
00058 //        Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
00059         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
00060 
00061         if ($this->getItemLimit('upsell') > 0) {
00062             $this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
00063         }
00064 
00065         $this->_itemCollection->load();
00066 
00067         /**
00068          * Updating collection with desired items
00069          */
00070         Mage::dispatchEvent('catalog_product_upsell', array(
00071             'product'       => $product,
00072             'collection'    => $this->_itemCollection,
00073             'limit'         => $this->getItemLimit()
00074         ));
00075 
00076         foreach ($this->_itemCollection as $product) {
00077             $product->setDoNotUseCategoryId(true);
00078         }
00079 
00080         return $this;
00081     }

getColumnCount (  ) 

Definition at line 115 of file Upsell.php.

00116     {
00117         return $this->_columnCount;
00118     }

getItemCollection (  ) 

Definition at line 89 of file Upsell.php.

00090     {
00091         return $this->_itemCollection;
00092     }

getItemLimit ( type = ''  ) 

Definition at line 149 of file Upsell.php.

00150     {
00151         if ($type == '') {
00152             return $this->_itemLimits;
00153         }
00154         if (isset($this->_itemLimits[$type])) {
00155             return $this->_itemLimits[$type];
00156         }
00157         else {
00158             return 0;
00159         }
00160     }

getItems (  ) 

Definition at line 94 of file Upsell.php.

00095     {
00096         if (is_null($this->_items)) {
00097             $this->_items = $this->getItemCollection()->getItems();
00098         }
00099         return $this->_items;
00100     }

getIterableItem (  ) 

Definition at line 126 of file Upsell.php.

00127     {
00128         $item = current($this->_items);
00129         next($this->_items);
00130         return $item;
00131     }

getRowCount (  ) 

Definition at line 102 of file Upsell.php.

00103     {
00104         return ceil(count($this->getItemCollection()->getItems())/$this->getColumnCount());
00105     }

resetItemsIterator (  ) 

Definition at line 120 of file Upsell.php.

00121     {
00122         $this->getItems();
00123         reset($this->_items);
00124     }

setColumnCount ( columns  ) 

Definition at line 107 of file Upsell.php.

00108     {
00109         if (intval($columns) > 0) {
00110             $this->_columnCount = intval($columns);
00111         }
00112         return $this;
00113     }

setItemLimit ( type,
limit 
)

Set how many items we need to show in upsell block Notice: this parametr will be also applied

Parameters:
string $type
int $limit
Returns:
Mage_Catalog_Block_Product_List_Upsell

Definition at line 141 of file Upsell.php.

00142     {
00143         if (intval($limit) > 0) {
00144             $this->_itemLimits[$type] = intval($limit);
00145         }
00146         return $this;
00147     }


Member Data Documentation

$_columnCount = 4 [protected]

Definition at line 37 of file Upsell.php.

$_itemCollection [protected]

Definition at line 41 of file Upsell.php.

$_itemLimits = array() [protected]

Definition at line 43 of file Upsell.php.

$_items [protected]

Definition at line 39 of file Upsell.php.


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

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