Monday, October 6, 2014

Magento get wishlist count in the header when a user is logged in

<code>
<?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
        <div class="header-wishlist-count">
            <span>
                <?php
                    $customer = Mage::getSingleton('customer/session')->getCustomer();
                    $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true);
                    // get the amount of items (2 of one item counts as 1)
                    echo $wishlist->getItemsCount();
                ?>
            </span>
        </div>
<?php endif; ?>
</code>

No comments:

Post a Comment