Public Member Functions | |
getLoadedProductCollection () | |
getMode () | |
getToolbarBlock () | |
getToolbarHtml () | |
setCollection ($collection) | |
addAttribute ($code) | |
getPriceBlockTemplate () | |
prepareSortableFieldsByCategory ($category) | |
getColumnCount () | |
addColumnCountLayoutDepend ($pageLayout, $columnCount) | |
removeColumnCountLayoutDepend ($pageLayout) | |
getColumnCountLayoutDepend ($pageLayout) | |
getPageLayout () | |
Protected Member Functions | |
_getProductCollection () | |
_beforeToHtml () | |
_getConfig () | |
Protected Attributes | |
$_defaultToolbarBlock = 'catalog/product_list_toolbar' | |
$_productCollection | |
$_defaultColumnCount = 3 | |
$_columnCountLayoutDepend = array() |
Definition at line 35 of file List.php.
_beforeToHtml | ( | ) | [protected] |
Need use as _prepareLayout - but problem in declaring collection from another block (was problem with search result)
Reimplemented from Mage_Core_Block_Abstract.
Definition at line 137 of file List.php.
00138 { 00139 /*$toolbar = $this->getLayout()->createBlock('catalog/product_list_toolbar', microtime()); 00140 if ($toolbarTemplate = $this->getToolbarTemplate()) { 00141 $toolbar->setTemplate($toolbarTemplate); 00142 }*/ 00143 $toolbar = $this->getToolbarBlock(); 00144 00145 // called prepare sortable parameters 00146 $collection = $this->_getProductCollection(); 00147 00148 // use sortable parameters 00149 if ($orders = $this->getAvailableOrders()) { 00150 $toolbar->setAvailableOrders($orders); 00151 } 00152 if ($sort = $this->getSortBy()) { 00153 $toolbar->setDefaultOrder($sort); 00154 } 00155 if ($modes = $this->getModes()) { 00156 $toolbar->setModes($modes); 00157 } 00158 00159 // set collection to tollbar and apply sort 00160 $toolbar->setCollection($collection); 00161 00162 $this->setChild('toolbar', $toolbar); 00163 Mage::dispatchEvent('catalog_block_product_list_collection', array( 00164 'collection'=>$this->_getProductCollection(), 00165 )); 00166 00167 $this->_getProductCollection()->load(); 00168 Mage::getModel('review/review')->appendSummary($this->_getProductCollection()); 00169 return parent::_beforeToHtml(); 00170 }
_getConfig | ( | ) | [protected] |
Retrieve Catalog Config object
Definition at line 220 of file List.php.
00221 { 00222 return Mage::getSingleton('catalog/config'); 00223 }
_getProductCollection | ( | ) | [protected] |
Retrieve loaded category collection
Reimplemented in Mage_Catalog_Block_Product_List_Promotion, and Mage_Catalog_Block_Product_List_Random.
Definition at line 72 of file List.php.
00073 { 00074 if (is_null($this->_productCollection)) { 00075 $layer = Mage::getSingleton('catalog/layer'); 00076 /* @var $layer Mage_Catalog_Model_Layer */ 00077 if ($this->getShowRootCategory()) { 00078 $this->setCategoryId(Mage::app()->getStore()->getRootCategoryId()); 00079 } 00080 00081 // if this is a product view page 00082 if (Mage::registry('product')) { 00083 // get collection of categories this product is associated with 00084 $categories = Mage::registry('product')->getCategoryCollection() 00085 ->setPage(1, 1) 00086 ->load(); 00087 // if the product is associated with any category 00088 if ($categories->count()) { 00089 // show products from this category 00090 $this->setCategoryId(current($categories->getIterator())); 00091 } 00092 } 00093 00094 $origCategory = null; 00095 if ($this->getCategoryId()) { 00096 $category = Mage::getModel('catalog/category')->load($this->getCategoryId()); 00097 if ($category->getId()) { 00098 $origCategory = $layer->getCurrentCategory(); 00099 $layer->setCurrentCategory($category); 00100 } 00101 } 00102 $this->_productCollection = $layer->getProductCollection(); 00103 00104 $this->prepareSortableFieldsByCategory($layer->getCurrentCategory()); 00105 00106 if ($origCategory) { 00107 $layer->setCurrentCategory($origCategory); 00108 } 00109 } 00110 return $this->_productCollection; 00111 }
addAttribute | ( | $ | code | ) |
Definition at line 204 of file List.php.
00205 { 00206 $this->_getProductCollection()->addAttributeToSelect($code); 00207 return $this; 00208 }
addColumnCountLayoutDepend | ( | $ | pageLayout, | |
$ | columnCount | |||
) |
Add row size depends on page layout
string | $pageLayout | |
int | $rowSize |
Definition at line 280 of file List.php.
00281 { 00282 $this->_columnCountLayoutDepend[$pageLayout] = $columnCount; 00283 return $this; 00284 }
getColumnCount | ( | ) |
Retrieve product amount per row in grid display mode
Definition at line 256 of file List.php.
00257 { 00258 if (!$this->_getData('column_count')) { 00259 $pageLayout = $this->getPageLayout(); 00260 if ($pageLayout && $this->getColumnCountLayoutDepend($pageLayout->getCode())) { 00261 $this->setData( 00262 'column_count', 00263 $this->getColumnCountLayoutDepend($pageLayout->getCode()) 00264 ); 00265 } else { 00266 $this->setData('column_count', $this->_defaultColumnCount); 00267 } 00268 } 00269 00270 return (int) $this->_getData('column_count'); 00271 }
getColumnCountLayoutDepend | ( | $ | pageLayout | ) |
Retrieve row size depends on page layout
string | $pageLayout |
Definition at line 307 of file List.php.
00308 { 00309 if (isset($this->_columnCountLayoutDepend[$pageLayout])) { 00310 return $this->_columnCountLayoutDepend[$pageLayout]; 00311 } 00312 00313 return false; 00314 }
getLoadedProductCollection | ( | ) |
Retrieve loaded category collection
Definition at line 118 of file List.php.
00119 { 00120 return $this->_getProductCollection(); 00121 }
getMode | ( | ) |
getPageLayout | ( | ) |
Retrieve current page layout
Definition at line 321 of file List.php.
00322 { 00323 return $this->helper('page/layout')->getCurrentPageLayout(); 00324 }
getPriceBlockTemplate | ( | ) |
getToolbarBlock | ( | ) |
Retrieve Toolbar block
Definition at line 177 of file List.php.
00178 { 00179 if ($blockName = $this->getToolbarBlockName()) { 00180 if ($block = $this->getLayout()->getBlock($blockName)) { 00181 return $block; 00182 } 00183 } 00184 $block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, microtime()); 00185 return $block; 00186 }
getToolbarHtml | ( | ) |
Retrieve list toolbar HTML
Definition at line 193 of file List.php.
00194 { 00195 return $this->getChildHtml('toolbar'); 00196 }
prepareSortableFieldsByCategory | ( | $ | category | ) |
Prepare Sort By fields from Category Data
Mage_Catalog_Model_Category | $category |
Definition at line 231 of file List.php.
00231 { 00232 if (!$this->getAvailableOrders()) { 00233 $this->setAvailableOrders($category->getAvailableSortByOptions()); 00234 } 00235 $availableOrders = $this->getAvailableOrders(); 00236 if (!$this->getSortBy()) { 00237 if ($categorySortBy = $category->getDefaultSortBy()) { 00238 if (!$availableOrders) { 00239 $availableOrders = $this->_getConfig()->getAttributeUsedForSortByArray(); 00240 } 00241 if (isset($availableOrders[$categorySortBy])) { 00242 $this->setSortBy($categorySortBy); 00243 } 00244 } 00245 } 00246 00247 00248 return $this; 00249 }
removeColumnCountLayoutDepend | ( | $ | pageLayout | ) |
Remove row size depends on page layout
string | $pageLayout |
Definition at line 292 of file List.php.
00293 { 00294 if (isset($this->_columnCountLayoutDepend[$pageLayout])) { 00295 unset($this->_columnCountLayoutDepend[$pageLayout]); 00296 } 00297 00298 return $this; 00299 }
setCollection | ( | $ | collection | ) |
$_defaultToolbarBlock = 'catalog/product_list_toolbar' [protected] |