How to override template file -


using custom module?


Create wishlist_index_index.xml File Under Vendor/ModuleName/view/frontend/layout/wishlist_index_index.xml

Add This Code :-

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
         <referenceBlock name="customer.wishlist.item.cart">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Vendor_ModuleName::item/column/cart.phtml</argument>

Create File On Vendor/ModuleName/view/frontend/templates/item/column/cart.phtml And Copy Paste Core cart.phtml file and change as per your requirement.

If You Used Theme Then Just Copy This File And Put In Vendor/ThemeName/Magento_Wishlist/view/frontend/templates/item/column/cart.phtml

  • Perfect answer!. can you tell me how to do the same for compare template? – Sanjun Dev Sep 18 '19 at 9:54
  • like Magento/module-catalog/view/frontend/template/product/compare/list.phtml – Sanjun Dev Sep 18 '19 at 10:04
  • using module or theme? – Rk Rathod Sep 18 '19 at 10:34
  • using custom module – Sanjun Dev Sep 18 '19 at 10:49

Simply put your template into your theme directory under <theme_dir>/<Vendor>_<Module>/view/frontend/templates/item/column/cart.phtml

Magento will automatically override all template files placed under the same path as in the core modules in your theme's directory.

  • I am using module, so is this work? – Sanjun Dev Sep 18 '19 at 9:53

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.