0

How to override Adminhtml template files in Magento 2.3? In a proper way.

File to override:

vendor/magento/module-sales/view/adminhtml/templates/order/totals.phtml
  • Which template file do you want to override? – Sumit Sep 18 at 11:08
  • vendor/magento/module-sales/view/adminhtml/templates/order/totals.phtml – Junaid Ashfaq Sep 18 at 11:12
  • Please check my answer. – Sumit Sep 18 at 11:45
2

For overriding vendor/magento/module-sales/view/adminhtml/templates/order/totals.phtml file you need to create a module.

Create sales_order_view.xml at

app/code/Your_VendorName/Your_ModuleName/view/adminhtml/layout/sales_order_view.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="order_totals">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Vendor_Module::order/totals.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Then Copy totals.phtml file from

vendor/magento/module-sales/view/adminhtml/templates/order/totals.phtml

To

app/code/Your_Vendor/Your_Module/view/adminhtml/templates/order/totals.phtml

Hope it helps!!!

0

First Step:

Path of the XML OSCP/ModuleName/view/adminhtml/layout/sales_order_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="column_name">
            <action method="setTemplate">
                <argument name="template" translate="true" xsi:type="string">OSCP_ModuleName::order/items/column/name.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Then copy the original file to

OSCP/ModuleName/view/adminhtml/templates/order/items/column/name.phtml

This is the Basic Pattern in Magento 2.3

  • i used this pattern but not working – Junaid Ashfaq Sep 18 at 11:15
  • <?xml version="1.0"?> <page xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="column_name"> <action method="setTemplate"> <argument name="template" translate="true" xsi:type="string">Vendor_Module::order/totals.phtml</argument> </action> </referenceBlock> </body> </page> – Junaid Ashfaq Sep 18 at 11:15
  • This is the Only way as Magento Said devdocs.magento.com/guides/v2.3/frontend-dev-guide/templates/… – Oscprofessionals Sep 18 at 11:26
  • not getting any error changes not happened – Junaid Ashfaq Sep 18 at 11:46
  • okay just echo "test"; and exit(); on the file path: OSCP/ModuleName/view/adminhtml/templates/order/items/column/name.phtml. and Check whether Echo prints or not. – Oscprofessionals Sep 18 at 11:47

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.