Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cristianstan/9228402 to your computer and use it in GitHub Desktop.
Save cristianstan/9228402 to your computer and use it in GitHub Desktop.
Magento: Limit number of products shown on homepage
<?php //Magento: Limit number of products shown on homepage, list.phtml ?>
1) app\design\frontend\default\<your theme>\template\catalog\product
copy list.phtml and save as list_new.phtml
2) <?php //Now open list_new.phtml and search '' after ending the if loop insert this code ?>
<?php if($i<=4): // for 4 product?>
3) <?php //Now open list_new.phtml and search '' after ending the if loop insert this code ?>
<?php endif // for 4 product?>
<?php // The code will look like this ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid">
<?php endif ?>
<?php if($i<=4): // for 4 product?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?>">
// some code here
</li>
<?php endif // for 4 product?>
2) Now go to CMS>Pages>select home page >content> and copy this code (change your categy id here)
{{block type="catalog/product_list" name="product_list" category_id="<category id>" column_count="4"mode="grid" template="catalog/product/list_new.phtml"}}
@bhargavmehta
Copy link

This is not working in magento 1.9.1 can you suggest an alternative method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment