Magento – Limit number of products displayed in random products block in Magento

countlimitmagentoproductrandom

How can the solution provided in Magento limit the number of products shown with in the new products block be applied to a random products block displayed on the home page?

I currently have the code

<reference name="random">
<block type="catalog/product_list_random" name="product_random" template="catalog/product/grid_only.phtml">
 <action method="setProductsCount"><count>3</count></action>
 </block>
    </reference>

in my layout update XML. The grid product view default value seems to be dominating this value which is set in the backend System > configuration > catalog > catalog > frontend > "Products per Page on Grid Default Value".

Best Answer

Take a look @

Also try changing

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

to

 <action method="setData"><key>num_products</key><value>[# to display]</value></action>

or

 <action method="setNumProducts"><num_products>[# to display]</num_products></action>

see /app/code/core/Mage/Catalog/Block/Product/List/Random.php

 $numProducts = $this->getNumProducts() ? $this->getNumProducts() : 0;

You could also try adding this to your cms page

{{block type="catalog/product_list_random" category_id="YOUR_CATEGORY_ID" template="catalog/product/list.phtml" column_count="4" num_products="12"}}