5

How to move compare product link into header, Right now it is in top links. So to do so I've tried putting following line in my default.xml

<move element="compare-products-link" destination="header-wrapper" />

But it's not working ,another alternative was by putting following line

<move element="catalog.compare.sidebar" destination="header-wrapper" />

But it's putting whole div structure and I don't want it, I just want to have link. so any suggestions??

1 Answer 1

5

The name of the element is catalog.compare.link as defined in Magento/Catalog/view/frontend/layout/default.xml :

        <block class="Magento\Framework\View\Element\Template" name="catalog.compare.link" before="-"
               template="Magento_Catalog::product/compare/link.phtml">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="compareProducts" xsi:type="array">
                            <item name="component" xsi:type="string">Magento_Catalog/js/view/compare-products</item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </block>

So you can call the following:

<move element="catalog.compare.link" destination="header-wrapper" />
3
  • 1
    Hey @Raphael at Digital Pianism, You are the always first one to answer my question every time , Thanks ;) and yes by using this catalog.compare.link I've just moved it and I closely watch my question and found the answer in my question itself :D Commented Aug 31, 2016 at 7:43
  • 1
    @KaushalSuthar I'm glad your problem is solved. Thanks for the compliment =) Commented Aug 31, 2016 at 7:43
  • @RaphaelatDigitalPianism How can I do this from a custom Magento 2.1.7 theme, instead of editing the default files? Commented Nov 20, 2017 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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