How to override the template file in magento 2

We override temples file of checkout/cart/index controller page

  • Create xml file in
app/code/[Name_Space]/[Your_Module]/view/frontend/ layout
<?xml version="1.0"?>

 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance dc" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

  <referenceBlock name="checkout.cart">

<action method="setTemplate">

<argument name="template" xsi:type="string">[Name_Space]_[Your_Module]::checkout_cart.phtml</argument>

   </action>

  </referenceBlock>

 </page>
  • cart: it’s a block name ,whose template file want to override
  • [Name_Space]_[Your_Module]::checkout_cart.phtml: it’s a template file for your module.
  • Create checkout_cart_phtml file

app/code/[Name_Space]/[Your_Module]/view/frontend/templates

I hope the following information helps you to override the template file in magento 2.

Last Update: April 9, 2018  

February 3, 2018   209   Nandini R    Operations    
Total 2 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook
Twitter
INSTAGRAM
LinkedIn