Limit the number of products displayed in a block of random products in Magento

advertisements

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".


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"}}