in Cms Page
Go to “CMS – Manage Pages” and select “Home Page” from the list of pages.
Use this code snippet to show one category on your front page:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}
For All Products
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}
in Phtml Page:
<?php /** * For current category */ $category = Mage::registry('current_category'); /** * For a specific category */ $categoryId = 10; $category = Mage::getModel('catalog/category')->load($categoryId); /** * Product collection for a particular category */ $productCollection = Mage::getResourceModel('catalog/product_collection') ->addCategoryFilter($category) ->addAttributeToSelect('*'); /** * Filter result for only visible or status enable products */ Mage::getSingleton('catalog/product_status') ->addVisibleFilterToCollection($prodCollection); Mage::getSingleton('catalog/product_visibility') ->addVisibleInCatalogFilterToCollection($prodCollection); /** * Printing category and products name */ echo '<strong>'.$category->getName().'</strong><br />'; foreach ($prodCollection as $val) { echo $val->getName() . '<br />'; } ?>
2 Comments
IBO · October 20, 2016 at 9:17 am
hey i want to ask, how do you know list category id. i didn’t see that anywhere.
Sushant Vishwas · October 20, 2016 at 9:34 am
In admin panel you can find your category id