I try to limit the new products on the homepage with the following code:

        <block type="catalog/product_new" template="catalog/product/homepage-new-products.phtml">
            <action method="setProductsCount"><count>2</count></action>

Unfortunately this does not work, the setProductsCount is ignored.


Take a look at Limit number of products shown on homepage, list.phtml

{{block type="catalog/product_list" limit="4" category_id="13" template="catalog/product/list.phtml"}}

To accomplish this using layout.xml then use setLimit

<action method="setLimit">4</action>


<block type="catalog/product_list" template="catalog/product/homepage-new-products.phtml">
    <action method="setLimit">4</action>
| improve this answer | |

If you look at the _getProductCollection() method in the class Mage_Catalog_Block_Product_New you will see that the blocks collection has no way to limit the actual list of items.

It can set the page count, using setProductsCount Theoretically you can use this to limit the result, by not placing a pager as part of the block display, thus only the first page will be shown - the end effect is just a limit of the first page of products.

A while back, I did come up with a away to insert a limit (product_count) to catalog list filters. In my examples I use the CMS {{block}} tags, but it should also work from standard layout directives

You can read about this via my blog entry: http://www.proxiblue.com.au/blog/smarter-cms-category-product-limits/

This is also available as a module via github: https://github.com/ProxiBlue/CatalogListFilters

| improve this answer | |
  • In it actually reads ->setPageSize($this->getProductsCount())->setCurPage(1) so it looks like it returns one page, of size getProductsCount(), there is a setProductsCount function, that's why OP is trying to call it like that in his question – Richard Oct 30 '14 at 8:21
  • good work .... it is help me a t today – Amit Bera Dec 4 '15 at 21:28
<action method="setColumnCount"><columns>2</columns></action>
<action method="setProductsCount"><count>2</count></action>

Try it like this

| improve this answer | |
  • Tried before, does not work either. – Michael Oct 29 '14 at 13:07
{{block type="catalog/product_new" products_count="2" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}

Try this one :)

| improve this answer | |

You can add "column_count" to use product limit

{{block type="catalog/product_new" column_count="5" template="catalog/product/new.phtml"}}

| improve this answer | |

You can achieve the same using


in your block class.

| improve this answer | |

setProductsCount and setColumnCount did not do this

setProductsCount is define current perpage collection

and setColumnCount define no of column for collection

you need to limit on collection using action method

 <action method="setLimit"></action>
| improve this answer | |

Try below code to display recent product:-

                            $allproduct = Mage::getModel('catalog/product')->getCollection()->setOrder('entity_id','desc')->setPageSize(5)->getData();
                            $_helper = $this->helper('catalog/output');
                            foreach($allproduct as $product){
                            echo '<div class="product_box">';
                            $obj = Mage::getModel('catalog/product');
                            $productid = $product['entity_id'];
                            $_product = $obj->load($productid); // Enter your Product Id in $product_id
                            $productName = $_product->getName();
                            $productDescription = $_product->getDescription();
                            $productImage = $_product->getImageUrl();
                            $productUrl = $_product->getProductUrl();
                            $productPrice = $_product->getPrice();
                            $addToCartUrl = Mage::helper('checkout/cart')->getAddUrl($_product);
                            echo '<a href="'.$productUrl.'"><img src="'.$productImage.'" alt="Shoes 1" /></a>';
                            echo '<p>"'.$productDescription.'"</p>';
                            echo '<p class="product_price">"'.$productPrice.'"</p>';
                            echo '<a href="'.$productUrl.'" class="detail"></a>';
                            echo "<div class='carousel-title'>";
                            echo $_product->getName();
                            echo "</div>";
                            echo '<a href="'.$addToCartUrl.'" class="addtocart"></a>';
                            echo '</div>';

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.