Magento 侧边栏购物车显示所有产品

第一种方法是后台 System > Configuration > Checkout > Shopping Cart Side Bar 设置(默认是显示3个),把参数设置过大到可以显示全部。

第二种当然就是修改代码:

把:

<?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 ?>

改为:

<?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 ?>

相关文章