3

I need to modify Magento2 form.mini.phtml to have Login, Register and Wishlist links. And after wishlist link, I need to display product count which are in the wishlist after login.

I know how to do this on Magento 1x but I'm confused how to get them on Magento 2.

1 Answer 1

4

Login link: $this->getUrl("customer/account/login")

Register link: $this->getUrl('customer/account/create')

For Wishlist link with product count:

<span data-bind="scope: 'wishlist'" class="link wishlist">
<a href="<?php echo $this->getUrl('wishlist') ?>">
    <?php echo __('My Wishlist') ?>
    <!-- ko if: wishlist().counter --><span data-bind="text: wishlist().counter" class="counter qty"></span><!-- /ko -->
</a>

</span>

You need to use this code: <!-- ko if: wishlist().counter --><span data-bind="text: wishlist().counter" class="counter qty"></span><!-- /ko --> to show product count (don't remove)

If you have removed Wishlist link on top links, you need to add javascript code (if not, ignore it):

<script type="text/x-magento-init">
{
    "*": {
        "Magento_Ui/js/core/app": {
            "components": {
                "wishlist": {
                    "component": "Magento_Wishlist/js/view/wishlist"
                }
            }
        }
    }
}

1
  • it worked well , thanks is there any way to customise wishlist count current it is "x Items" but I need to display it as "(x)" items Dec 22, 2015 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.