Magento Get all products in cart instead of most recent

George picture George · Dec 27, 2012 · Viewed 7.9k times · Source

I am adapting the modern theme to create a new theme to use.

I need to display all the products in the customers basket. I have this code and currently it only displays up to three items. Is there a different command I can use instead of getRecentItems() to display all the items in their basket? I tried using getAllItems() but this does not seem to do anything.

 <?php $items = $this->getRecentItems();?>
        <?php if(count($items)): ?>
            <ol id="cart-header" class="mini-products-list">
                <?php foreach($items as $item): ?>
                    <?php echo $this->getItemHtml($item) ?>
                <?php endforeach; ?>
            </ol>
        <?php else: ?>
            <?php echo $this->__('There are no items in your shopping Basket.') ?>
        <?php endif ?>

Any Ideas ?

Answer

Tom S picture Tom S · Dec 27, 2012

Check in System > Configuration > Checkout > Shopping Cart Side Bar

There is a setting to set the number of products that can be visible in the mini cart.

Maximum Display Recently Added Item(s) by default is 3. Increase it to what you want it to be or rather a high number to always show all products in the cart.

EDIT: To override the default magento behavior based on your comments you could use the following.

<?php
    $session= Mage::getSingleton('checkout/session');
    $items = $session->getQuote()->getAllItems();
?>
        <?php if(count($items)): ?>
            <ol id="cart-header" class="mini-products-list">
                <?php foreach($items as $item): ?>
                    <?php echo $this->getItemHtml($item) ?>
                <?php endforeach; ?>
            </ol>
        <?php else: ?>
            <?php echo $this->__('There are no items in your shopping Basket.') ?>
        <?php endif ?>