5

Can anyone help how to override

vendor/magento/module-sales/view/adminhtml/templates/items/column/name.phtml file.
3

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>
| improve this answer | |
  • Yes Correct, it is called multiple instances. – Gagan Sep 14 '18 at 13:22
  • @Amit : above code working but if we are going to shipment of order then this is not working. For name.phtml which xml we should override? – Charul Tyagi Mar 7 '19 at 11:58
1

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
| improve this answer | |
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

| improve this answer | |
  • it's rare to create a theme for admin, I don't think that it's the right solution. – PЯINCƏ Sep 14 '18 at 9:22
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!

| improve this answer | |
  • Thanks, but I'm referring on overriding the template from the admin's end. – Jm Cabugnason Sep 14 '18 at 7:35
  • then your file will be here magento\app\design\adminhtml\YourVendor\YourThemeName\Magento_Backend\view\adminhtml\templates\product\some.phtml – Sanjay Vadadoriya Sep 14 '18 at 7:39
  • Up vote my answer if helpful.. your welcome :) – Sanjay Vadadoriya Sep 14 '18 at 8:16
  • I already upvote it. But it will not reflect publicly since I have a low reputation. – Jm Cabugnason Sep 14 '18 at 8:19
  • He is looking for admin template, how do you want him to put it on` frontend` as you response ? – PЯINCƏ Sep 14 '18 at 9:11
0

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

| improve this answer | |

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.