Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Get all products in cart instead of most recent

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 ?

like image 336
George Avatar asked Dec 27 '12 22:12

George


2 Answers

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 ?>
like image 186
Tom S Avatar answered Sep 20 '22 17:09

Tom S


The Mage_Checkout_Block_Cart_Sidebar method getRecentItems() accepts a count param, just call it in this way to retrieve the full cart items.

<?php $items = $this->getRecentItems(10000);?>
like image 20
Visualwebs Avatar answered Sep 20 '22 17:09

Visualwebs