Magento limits the number of products shown in the new product block

How to limit the number of products shown in the new products block? via cms / pages / design / Layout update XML

<block type="catalog/product_new" name="home.catalog.product.new" template="catalog/product/new.phtml" > <action method="setColumnCount"><count>5</count></action> <action method="setLimit"><limit>5</limit></action> </block> 

setLimit does not work, and

 <action method="setDefaultGridPerPage"><limit>5</limit></action> 

or

 <action method="setData"><key>limit</key><value>3</value></action> 

or

 <action method="setProductLimit"><count>5</count></action> 

or

 <action method="setProductsLimit"><count>5</count></action> 

or

 <action method="setProductsCount"><count>5</count></action> 
+4
source share
2 answers

Try

  <action method="setProductsCount"><count>5</count></action> 

See / app / code / core / Mage / Catalog / Block / Product / New.php

 /** * Set how much product should be displayed at once. * * @param $count * @return Mage_Catalog_Block_Product_New */ public function setProductsCount($count) { $this->_productsCount = $count; return $this; } 

Read more @ http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page

+5
source

Do not try this randomly. You are trying to invoke an action on block/product_new . So, go to the Mage_Catalog_Block_Product_Abstract class and see which function can perform the task (double Ctrl + O in eclipse)

Here I see the function Mage_Catalog_Block_Product_Abstract::addColumnCountLayoutDepend($pageLayout, $columnCount) .

Perhaps this may help you. Example:

 $this->addColumnCountLayoutDepend('one_column', 5) 
0
source

Source: https://habr.com/ru/post/1441824/


All Articles