0

I would like to overide the following admin template src/vendor/magento/module-sales/view/adminhtml/templates/order/view/history.phtml

This is what I made

module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Cpy_Sales" setup_version="0.1.0">
        <sequence>
            <module name="Magento_Sales" />
        </sequence>
    </module>
</config>

Cpy/Sales/view/adminhtml/layout/sales_order_view.xml

Already have one extend there for the items, this one seems to be fine

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="order_items">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Cpy_Sales::order/view/items.phtml</argument>
            </action>
        </referenceBlock>
        <referenceBlock name='order_history'>
            <arguments>
                <argument name='template' xsi:type='string'>Cpy_Sales::order/view/history.phtml</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Then my custom template is in : src/app/code/Cpy/Sales/view/adminhtml/templates/order/view/history.phtml This template is basically the same but add an automatic "checked" attribute to the input history[is_customer_notified] so there is nothing very magical in there.

2
  • make sure your module is installed and enabled as well.
    – Pawan
    Aug 27 at 9:04
  • it is, already existing; and as I said the order_items is already overrided in there
    – Claims
    Aug 27 at 9:09
2

try replacing

<referenceBlock name='order_history'>
    <arguments>
       <argument name='template' xsi:type='string'>Cpy_Sales::order/view/history.phtml</argument>
   </arguments>
</referenceBlock>

with

<referenceBlock name='order_history'>
    <action method="setTemplate">
        <argument name='template' xsi:type='string'>Cpy_Sales::order/view/history.phtml</argument>
     </action>
</referenceBlock>
1
  • I just figure it out, this is the way. I should have took more care about what I had above more than finding it on the web. I still don't know where this difference comes from. May be different magento version. Still it works, thanks !
    – Claims
    Aug 27 at 9:25

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.