Magento How to display upsell products under cart page

Magento How to display upsell products under cart page

July 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento How to display upsell products under cart page

Displaying upsell products under the cart page in Magento involves several steps.

Understanding Upsell Products

Upsell products are items that are related to the product currently being viewed or added to the cart. They are typically displayed alongside the main product with the aim of encouraging customers to purchase additional, complementary items.

In your case, you have already created an upsell block and attempted to call it on the cart page using this code:

<?php if(count($this->getItemCollection()->getItems())): ?>
<div class="box-collateral box-up-sell">
    <div class="box-title">
        <h2><?php echo $this->__('You may also be interested in the following product(s)') ?></h2>
    </div>
    <ul class="products-grid" id="upsell-product-list">
    <?php // $this->setColumnCount(5); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
    <?php $this->resetItemsIterator() ?>
    <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
        <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
            <?php if($_link=$this->getIterableItem()): ?>
            <li class="item">
                <a href="<?php echo $_link->getProductUrl() ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" title="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a>
                <h3 class="product-name"><a href="<?php echo $_link->getProductUrl() ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></h3>
                <?php echo $this->getReviewsSummaryHtml($_link) ?>
                <?php echo $this->getPriceHtml($_link, true, '-upsell') ?>
            </li>
            <?php endif; ?>
        <?php endfor; ?>
    <?php endfor; ?>
    </ul>
    <script type="text/javascript">decorateList('upsell-product-list', 'none-recursive')</script>
</div>
<?php endif ?>

This code is correctly structured to display upsell products in a grid format. It uses Magento’s built-in methods like getIterableItem() and getProductUrl() to retrieve product information.

The Issue

The issue you’re facing seems to be that the $this->getItemCollection()->getItems() condition always returns empty, preventing the upsell block from being rendered.

This could happen for a few reasons:

  1. Upsell Products Not Configured: Ensure that you have actually configured upsell products for the main product in your cart. You can do this by going to the product details page and selecting the “Related Products” tab.

  2. Product Status: Make sure all the upsell products are enabled (in catalog > manage products) and have at least one image assigned.

  3. Cache Clearance: Magento uses cache heavily, so make sure you clear your cache after making any changes to ensure they take effect.

Solution

If everything is configured correctly but the upsell block still isn’t being rendered, try adding some debugging statements to check what’s going wrong:

<?php if(count($this->getItemCollection()->getItems())): ?>
    <p>Number of items: <?php echo count($this->getItemCollection()->getItems()) ?></p>
    <p>First item: <?php print_r($this->getIterableItem()) ?></p>
<?php endif ?>

This will help you see if the getItemCollection() method is returning any data.

Conclusion

Displaying upsell products under the cart page requires correctly configuring your upsell products and ensuring that all related settings are correct. If the code is structured properly but no upsell items are being displayed, double-check your product configuration and Magento cache settings.

Remember to always update your Magento version regularly and follow best practices for theme development to avoid such issues.

For more detailed guides on customizing Magento themes and blocks, I recommend checking out Laravel Company’s Magento tutorials. They provide comprehensive step-by-step guides that can help you solve complex Magento problems efficiently.

Checkout Catalog API Themes

Our network