2

I have to override Magento_Sales::order/items.phtml frontend template in custom module. I have added below code to sales_order_view.xml file of my module.

<?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="order_items">
        <arguments>
            <argument name="template" xsi:type="string">Vendor_Module::order/items.phtml</argument>
        </arguments>
    </referenceBlock>
</body>
</page>

It throws below exception

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'arguments': This element is not expected.

How I can override mentioned phtml file ? I have followed this answer but it throws same exception.

Edit: As action node is deprecated, I do not want to use it.

3 Answers 3

1

You need to use the below code for your 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="order_items">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Vendor_Module::order/items.phtml</argument>
        </action>
    </referenceBlock>
</body>
</page>

Alternative solution:

<?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="order_items" template="Vendor_Module::order/items.phtml"/>
    </body>
</page>
7
0

Try below solution:

 <referenceBlock name="order_items">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Vendor_Module::order/items.phtml</argument>
            </action>

    </referenceBlock>
2
  • I have seen action node is deprecated. Is there any alternative?
    – amitshree
    Aug 8, 2018 at 7:23
  • yes, you are right . it is deprecated now
    – Amit Bera
    Aug 8, 2018 at 7:31
0

If you want to override front end template than you have to specify action method. without action Magento can't interpret what you want to override.

So try below 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="order_items">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Vendor_Module::order/items.phtml</argument>
        </action>
    </referenceBlock>
</body>
</page>

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.