0

How to override below admin file in my custom admin theme ?

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

Front-end and Back-end theme have same file structure.For customize or change something from the parent theme all you need to do is copy the file you want to change (layout, template) to your theme from the specific module and do your changes.

Points to remember:

  • To create the back-end/front-end theme, you need to create a new module
  • To apply front-end theme you can active from back-end.

Reference: http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/theme-apply.html

  • To apply back-end theme you need to specify in etc/di.xml file

Reference: http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/admin_theme_apply.html

1. How to create admin theme

create theme.xml: file in app/design/adminhtml/<yourpackage>/<yourtheme>/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>My Theme Tile</title>
    <parent>Magento/backend</parent> 
</theme>

Register theme : create registration.php in app/design/adminhtml/<yourpackage>/<yourtheme>/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'adminhtml/yourpackage/yourtheme',
    __DIR__
);

module.xml: in app/design/adminhtml/<yourpackage>/<yourtheme>/theme.xml and sequence xml element to make sure your theme gets loaded last.

<config>
    <module name="<yourpackage>_<yourtheme>" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Theme"/>
        </sequence>
    </module>
</config>

Enable theme:

etc/di.xml: app/design/adminhtml/<yourpackage>/<yourtheme>/etc/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Theme\Model\View\Design">
        <arguments>
            <argument name="themes" xsi:type="array">
                <item name="adminhtml" xsi:type="string">yourpackage/yourtheme</item>
            </argument>
        </arguments>
    </type>
</config>

enter image description here

Now run php bin/magento setup:upgrade and php bin/magento setup:static-content:deploy from your magento root directory

Override

Now theme all set come to customize part if you need to change any file just copy from Magento_root_directory\vendor\magento\ for frontend and back-end.

Example:

Override sales order view page : just need to create xml file in your module to override.

app/code/{yourpackage}/{yourtheme}/view/adminhtml/layout/sales_order_view.xml copy from Magento-root-directory\vendor\magento\module-sales\view\adminhtml\layout\sales_order_view.xml

<referenceBlock name='order_info'>
  <arguments>
    <argument name='template' xsi:type='string'>Vendor_Module::order/view/info.phtml</argument>
  </arguments>
</referenceBlock>

Don't forget to add Load custom module layout after sales

app/code/{yourpackage}/{yourtheme}/etc/module.xml

<sequence>
        <module name="Magento_Sales"/>
</sequence>

and all changes here..

app/design/adminhtml/{yourpackage}/{yourtheme}/Magento_Sales/templates/order/view/info.phtml

14
  • Thanks for reply. do you have any idea how to create and apply custom admin theme in backend Apr 27 '18 at 5:35
  • I have created devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/… this way but didn;t apply my theme in admin Apr 27 '18 at 5:44
  • Do we need to create module.xml in app/design/adminhtml/Vendor/Themename/module.xml and etc/di.xml in app/design/adminhtml/Vendor/Themename/etc/di.xml Apr 27 '18 at 6:01
  • Create a separate MyVendor_MyBackendTheme module and specify in '<module>/etc/di.xml' Apr 27 '18 at 6:05
  • @hweb87 The steps are the same, but instead of frontend use adminhtml in the folder structure. Apr 27 '18 at 6:21
0

Try app/design/adminhtml/<Vendor>/<admin_theme>/Magento_Sales/templates/order/view/info.phtml

You can read on how to create an admin theme at http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/admin_theme_create.html

2
-1

Create app/design/frontend/Vendor_Name/Theme_Name/Magento_Sales/templates/order/view/info.phtml in your custom admin theme.

Hope this helps you.

2
  • No, we can't edit in module-sales Apr 27 '18 at 5:34
  • Add info.phtml in your custom theme at module-sales/templates/order/view/info.phtml We are overriding the core template. Apr 27 '18 at 5:45

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.