6

Can anyone help how to override

vendor/magento/module-sales/view/adminhtml/templates/items/column/name.phtml file.
Teja Bhagavan Kollepara
  • 3,816
  • 5
  • 32
  • 69
Jm Cabugnason
  • 171
  • 1
  • 9

5 Answers5

4

At Magento2, from 7 layout items/column/name.phtml called

  • sales_order_creditmemo_new.xml

  • sales_order_creditmemo_updateqty.xml

  • sales_order_creditmemo_view.xml
  • sales_order_invoice_new.xml
  • sales_order_invoice_updateqty.xml
  • sales_order_invoice_view.xml
  • sales_order_view.xml

That you need to identify for which page, you want rewrite name.phtml.

So, you will found out respective layout file and have to create that layout file on your custom module as mention by Michell process.

Suppose, you want to changes at invoice create page. Then have to create

1.app/code/Company/Module/view/adminhtml/layout/sales_order_invoice_new.xml

Code

<?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" template="Company_Module::orders/items/column/name.phtml"/>
    </body>
</page>
Amit Bera
  • 77,456
  • 20
  • 123
  • 237
2

This is very simple, follow my guide below :

Step 1 : create file :

app/code/Company/Module/view/adminhtml/layout/sales_order_view.xml

With content :

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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" xsi:type="string">Company_Module::orders/items/column/name.phtml</argument>
            </action> 
        </referenceBlock>
    </body>
</page>

Step 2 : create phtml file :

app/code/Company/Module/view/adminhtml/templates/orders/items/column/name.phtml

Then put your code here
0

You just need to make app/design/adminhtml/templates/items/column/name.phtml(write your custom code here)

then do setup upgrade and setup static-content deploy

php bin/magento s:up

php bin/magento s:s:d

Rutvee Sojitra
  • 3,881
  • 2
  • 17
  • 55
0

override templates(.phtml) using custom theme

if you want to override vendor\magento\module-sales\view\adminhtml\templates\items\name.phtml first you need to create your custom theme, please refer this link for how to create a custom theme.

after that create phtml file in your custom theme to override the default one

 app/design/frontend/vendor-name/theme-name/Magento_Catalog/templates/product/some.phtml

finally, clear the cache of Magento as well as the browser, then check your page, new phtml file only reflected.

in this way you can override templates

Best of Luck!

Rama Chandran M
  • 3,210
  • 13
  • 22
  • 38
0

I figured it how to achieve. I just created a theme specifically for backend and from there I extend the module.

Teja Bhagavan Kollepara
  • 3,816
  • 5
  • 32
  • 69
Jm Cabugnason
  • 171
  • 1
  • 9