Show a CATEGORY and its products on Homepage, Magento1.9

Show a CATEGORY and its products on Homepage, Magento1.9

September 13, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Show a CATEGORY and its products on Homepage, Magento1.9

Displaying a Category and Its Products on Homepage in Magento 1.9

In Magento 1.9, you can display a specific category along with its products directly on the homepage using a combination of core functions and template files. Let’s walk through the process step-by-step.

Step 1: Understand the Core Module Structure

Magento’s core provides a catalog/product_list block that can be used to display product lists across different pages, including the frontend homepage (index/index.phtml). To show a specific category’s products on the homepage, we need to modify two key files:

  • app/code/core/Mage/Catalog/Block/Product.php
  • app/design/frontend/<your_package>/<your_theme>/template/catalog/product/list.phtml

Step 2: Modify the Product Block

Open app/code/core/Mage/Catalog/Block/Product.php and find the _getProductCollection() method. This is where you can filter products based on category.

public function _getProductCollection()
{
    if (is_null($this->_productCollection)) {
        $category = Mage::registry('current_category');
        // Change this line for your specific needs
        $categoryId = 12; // Replace with the desired category ID

        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
            ->joinField('category_id', 'catalog/category_product', 'category_id',
                'product_id=entity_id', null, 'left');

        if ($category) {
            $collection->addCategoryFilter($category);
        } else {
            $collection->addCategoryFilter(Mage::registry('current_category'));
        }

        // Apply category ID filter
        $collection->addAttributeToFilter('category_id', array('in' => array($categoryId)));

        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

        $this->_productCollection = $collection;
    }

    return $this->_productCollection;
}

Step 3: Modify the Product List Template

Open app/design/frontend/<your_package>/<your_theme>/template/catalog/product/list.phtml. You’ll notice it’s using a foreach loop to display products. To ensure only the desired category’s products are shown, update this section:

<?php if (!($this->getCollection()->count())): ?>
    <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
    <?php else: ?>
        <script type="text/javascript">decorateGeneric($$('ul.products li'));

</script>

<?php foreach ($this->getCollection() as $_product): ?>
    <?php if ($_product->isVisibleInSiteVisibility() && $_product->isSaleable()): ?>
        <div class="product-item">
            <a href="<?php echo $this->getProductUrl($_product) ?>" title="<?php echo $this->stripTags($this->getProductName($_product), null, true) ?>"><?php echo $this->escapeHtml($this->getProductName($_product)) ?></a>
            <?php if ($_helper = $this->helper('catalog/output')): ?>
                <div class="price-box">
                    <p class="special-price">
                        <span class="price">$
                            <?php echo $_helper->currency($_product->getFinalPrice(), true, false); ?>
                        </span>
                    </p>
                </div>
            <?php endif; ?>

            <!-- Show the desired product details here -->
        </div>
    <?php endif; ?>
<?php endforeach; ?>

Step 4: Update Your Category ID

In both files above, replace 12 with the actual category ID you want to display on your homepage.

Conclusion

By following these steps, you should now be able to display a specific category and its products directly on your Magento 1.9 homepage. Remember to always backup your files before making changes and test thoroughly in a development environment first.

For more advanced customization options or if you require assistance with this process, please don’t hesitate to reach out to our expert team at Laravel Company.

This guide assumes you have a basic understanding of Magento’s core structure and file editing. If you’re new to Magento development, consider checking out some of our beginner-friendly tutorials on Laravel Company for additional support.

Happy coding!

Magento 1 Catalog Extensions Themes

Our network