cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help Overriding a Template in Magento 2

Need Help Overriding a Template in Magento 2

Hi everyone, I know there are many threads relating to this, but I have looked through many of them and I cannot find a solution to my problem.

 

I need to override this template: /var/www/html/magento/vendor/magento/module-sales/view/frontend/templates/order/info.phtml

 

I have created a custom module called Vendor_Sales

 

Inside the Sales module, I have the following two files:

 

1) /var/www/html/magento/app/code/Vendor/Sales/view/frontend/layout/plant_information_index.xml

 

plant_information_index.xml contains:

 

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>


        <!-- Remove the original Contact Form -->
        <referenceBlock name="Magento\Sales\Block\Order\Info" remove="true"/>


        <!-- Add a custom Contact Form -->
        <referenceContainer name="content">
            <block class="Magento\Sales\Block\Order\Info" name="sales" template="Vendor_Sales:Smiley Surprisedrder/info.phtml" />
        </referenceContainer>


    </body>
</page>
 
2) /var/www/html/magento/app/code/Consnet/Sales/view/frontend/template/order/info.phtml
 
Which is the template that I have edited.
 
My problem is that the template is not changing and I do not know why. I also have all the other files required for a custom module such as module.xml, routes.xml, and registration.php. I do not believe they are necessary? Any help would be appreciated.
1 REPLY 1

Re: Need Help Overriding a Template in Magento 2

follow this link 

https://webkul.com/blog/override-phtml-file-magento2/


@suhailcons9a05 wrote:

Hi everyone, I know there are many threads relating to this, but I have looked through many of them and I cannot find a solution to my problem.

 

I need to override this template: /var/www/html/magento/vendor/magento/module-sales/view/frontend/templates/order/info.phtml

 

I have created a custom module called Vendor_Sales

 

Inside the Sales module, I have the following two files:

 

1) /var/www/html/magento/app/code/Vendor/Sales/view/frontend/layout/plant_information_index.xml

 

plant_information_index.xml contains:

 

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>


        <!-- Remove the original Contact Form -->
        <referenceBlock name="Magento\Sales\Block\Order\Info" remove="true"/>


        <!-- Add a custom Contact Form -->
        <referenceContainer name="content">
            <block class="Magento\Sales\Block\Order\Info" name="sales" template="Vendor_Sales:Smiley Surprisedrder/info.phtml" />
        </referenceContainer>


    </body>
</page>
 
2) /var/www/html/magento/app/code/Consnet/Sales/view/frontend/template/order/info.phtml
 
Which is the template that I have edited.
 
My problem is that the template is not changing and I do not know why. I also have all the other files required for a custom module such as module.xml, routes.xml, and registration.php. I do not believe they are necessary? Any help would be appreciated.