3

I've created an override by copying the original file here and then making my changes:

app/code/Vendor/Module/view/adminhtml/templates/order/create/items/grid.phtml

I have created a layout XML to remove blocks (named "items_grid") associated with the original layout folder, and then use my override file instead. (Assuming I've done correctly)

app/code/Vendor/Module/view/adminhtml/layout/sales_order_create_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="items_grid" remove="true"/>
        <referenceBlock name="content">
            <block class="Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid" template="Vendor_Module::order/create/items/grid.phtml" name="items_grid_new">
            </block>
        </referenceBlock>
    </body>
</page>

However, when I load the page, I received the below error:

Fatal error: Uncaught Error: Call to a member function getItems() on boolean in vendor/magento/module-sales/Block/Adminhtml/Order/Create/Items/Grid.php on line 132

Note: When I checked my code by updating directly in the core file, it worked fine. It just seems to be this override module setup that's causing the issue.

  • Maybe you make a mistake when call function in phtml file. Pls post your code in that phtml file. – Nero Phung Nov 29 '17 at 4:04
0

So, I can't tell how I came to this answer as I received help elsewhere, but this layout XML seemed to fix the problem in the end:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="items_grid">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Vendor_Module::order/create/items/grid.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Hopefully, we can learn something from the solution

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.