magento - how to display only one category of products in home page

magento - how to display only one category of products in home page

October 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
magento - how to display only one category of products in home page

Displaying Products from a Single Category on Magento Home Page

In Magento, displaying products from a specific category on the home page can be achieved by using the catalog/product_list block type and specifying the desired category ID. However, you are currently facing an issue where the products are not being displayed correctly.

Understanding the Problem

The core of your problem lies in how you are loading the product collection and displaying it in the CMS home page. When you use the following code to load the product collection:

$_productCollection=$this->getLoadedProductCollection();

It seems that the product collection is not being filtered correctly, resulting in no products being displayed with the message “There are no products matching the selection.”

On the other hand, when you replace this code with a direct model call to get the product collection:

$_productCollection = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('visibility', 4)
    ->addAttributeToFilter('status', 1)
    ->load();

You are able to display all the products in the catalog, regardless of the category specified on the home page.

The Root Cause

The issue appears to be related to how Magento handles the product display logic when using blocks within CMS pages. By default, the getLoadedProductCollection() method is expected to return a collection filtered by the current context (e.g., the selected category).

However, in your specific setup where you are manually adding the category_id parameter to the block call:

{{block type="catalog/product_list" category_id="24" template="catalog/product/list-home.phtml"}}

The filter is not being applied automatically. This leads to the product collection being loaded without any category constraints, resulting in all products being displayed.

The Solution

To fix this issue and display only the products from the specified category on the home page, you need to modify both your CMS block call and the list-home.phtml template file.

Step 1: Modify the CMS Block Call

Update the block call in your CMS home page as follows:

{{block type="catalog/product_list" name="home_product_list" category_id="24" template="catalog/product/list-home.phtml"}}

We are adding a unique block name home_product_list to allow for proper rendering and filtering of the products.

Step 2: Modify the list-home.phtml Template

In your list-home.phtml template file, update the product collection loading logic as follows:

<?php
$_productCollection = $this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>

<?php if (!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
    <?php $_collectionSize = $_productCollection->count() ?>
    <?php $_columnCount = $this->getColumnCount();?>
    <ul class="products-grid row">
        <?php $i=0; foreach ($_productCollection as $_product): ?>
            <?php /* if ($i++%$_columnCount==0): ?>
                <ul class="products-grid row">
                <?php endif */ ?>
            <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>  col-sm-4 col-xs-6">
                <!-- Product listing content -->
            </li>
            <?php /*  if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
                </ul>
            <?php endif */ ?>
        <?php endforeach ?>
    </ul>
</div>
<?php endif; ?>

In this updated code, we are using the $this->getLoadedProductCollection() method to load the product collection. This method should now correctly filter the products based on the category_id specified in the block call.

Conclusion

To display only one category of products on the Magento home page, make sure you update both your CMS block call and the corresponding template file as described above. By using a unique block name and ensuring that the product collection loading logic is correctly implemented, you should now be able to see the desired list of products from the specified category.

Remember to clear the cache after making these changes for them to take effect.

If you still encounter any issues or need further assistance with Magento development, feel free to visit Laravel Company for expert guidance and solutions.

Catalog Themes Errors

Our network