8

I am attempting to modify some arguments for a block that is defined in module-sales/view/adminhtml/layout/sales_order_view.xml on line 41.

<block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" template="order/view/items/renderer/default.phtml">

The problem, is that the block is not defined with a name, it only has an alias, so I am unable to use something like <referenceBlock name="default"/> to modify it.

I need to modify the "columns" argument inside this block. Is there any other way to reference this block, or am I pretty much out of luck?

1

2 Answers 2

2

You have to just override using below way,

app/design/frontend/{Vendor}/{themename}/Magento_Sales/layout/sales_order_view.xml file

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 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>
        <referenceContainer name="page.main.title">
            <block class="Magento\Sales\Block\Order\Info" name="order.status" template="order/order_status.phtml"/>
            <block class="Magento\Sales\Block\Order\Info" name="order.date" template="order/order_date.phtml"/>
            <container name="order.actions.container" htmlTag="div" htmlClass="actions-toolbar order-actions-toolbar">
                <block class="Magento\Sales\Block\Order\Info\Buttons" as="buttons" name="sales.order.info.buttons" cacheable="false"/>
            </container>
        </referenceContainer>
        <referenceContainer name="sales.order.info.buttons">
            <block class="Magento\Sales\Block\Order\Info\Buttons\Rss" as="buttons.rss" name="sales.order.info.buttons.rss" cacheable="false"/>
        </referenceContainer>
        <referenceContainer name="content">
            <block class="Magento\Sales\Block\Order\View" name="order.comments" template="order/order_comments.phtml" before="sales.order.info.links"/>
            <block class="Magento\Sales\Block\Order\View" name="sales.order.view" cacheable="false" after="sales.order.info.links">
                <block class="Magento\Sales\Block\Order\Items" name="order_items" template="order/items.phtml">
                    <block class="Magento\Framework\View\Element\RendererList" name="sales.order.items.renderers" as="renderer.list"/>
                    <block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml">
                        <arguments>
                            <argument name="label_properties" xsi:type="string">colspan="2" class="mark"</argument>
                            <argument name="value_properties" xsi:type="string">class="amount"</argument>
                        </arguments>
                        <block class="Magento\Tax\Block\Sales\Order\Tax" name="tax" template="order/tax.phtml"/>
                    </block>
                </block>
            </block>
            <block class="Magento\Sales\Block\Order\Info" as="info" name="sales.order.info" after="sales.order.view"/>
        </referenceContainer>
        <block class="Magento\Framework\View\Element\Template" name="additional.product.info" template="Magento_Theme::template.phtml"/>
    </body>
</page>

You can change colspan in above file.

2
  • 4
    Surely there has to be a better way than copying the full file
    – Ben Crook
    Jan 5, 2017 at 10:23
  • @BenCrook Not to mention, this does not help if a module wants to modify that template. The solution only works if done in a theme. There's a nasty hack here: magento.stackexchange.com/a/157608 Feb 27, 2018 at 20:29
0

Not the best solution, but it works as long as you are using simple type products. I think magento left this part unfinished. Also 'discont' is misspelled there(kinda funny):

<block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" name="simple" as="simple" template="order/view/items/renderer/default.phtml">
            <arguments>
                <argument name="columns" xsi:type="array">
                    <item name="product" xsi:type="string" translate="false">col-product</item>
                    <item name="status" xsi:type="string" translate="false">col-status</item>
                    <item name="price-original" xsi:type="string" translate="false">col-price-original</item>
                    <item name="price" xsi:type="string" translate="false">col-price</item>
                    <item name="qty" xsi:type="string" translate="false">col-ordered-qty</item>
                    <item name="subtotal" xsi:type="string" translate="false">col-subtotal</item>
                    <item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item>
                    <item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item>
                    <item name="discont" xsi:type="string" translate="false">col-discont</item>
                    <item name="total" xsi:type="string" translate="false">col-total</item>
                    <item name="action" xsi:type="string" translate="false">col-action</item>
                </argument>
            </arguments>
        </block>

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.