Magento2 Admin Sales Order – Remove Columns from Admin Sales Order View Page Items Grid

columnmagento2sales-orderview

Can anyone let me know how to remove existing columns from Admin->Sales->Order->View->Items Grid? Moreover, I also need to add a new column in the same grid, please find attached screenshot for your reference:
order view page items grid

I have tried to override vendor/magento/module-sales/view/adminhtml/layout/sales_order_view.xml file in my module and removed some of the columns but it throws the following error.

[2018-10-02 09:18:58] main.CRITICAL: The element 'order_items' already has a child with alias 'default' {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): The element 'order_items' already has a child with alias 'default' at /var/www/html/bannerbuzzmagento2/vendor/magento/framework/Data/Structure.php:611)"} []
[2018-10-02 09:18:59] main.CRITICAL: Invalid block type: Namespace\Module\Block\Adminhtml\DefaultRenderer {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): Invalid block type: Namespace\\Module\\Block\\Adminhtml\\DefaultRenderer at /var/www/html/bannerbuzzmagento2/vendor/magento/framework/View/Layout/Generator/Block.php:275, ReflectionException(code: -1): Class Namespace\\Module\\Block\\Adminhtml\\DefaultRenderer does not exist at /var/www/html/bannerbuzzmagento2/vendor/magento/framework/Code/Reader/ClassReader.php:19)"} []

Best Answer

You can Try this its work for me.

Add sales_order_view.xml file in your custom module Packagename/Modulename/view/adminhtml/layout and remove column as per your requirement.

<block class="Magento\Sales\Block\Adminhtml\Order\View\Items" name="order_items" template="Magento_Sales::order/view/items.phtml">
                        <arguments>
                            <argument name="columns" xsi:type="array">
                                <item name="product" xsi:type="string" translate="true">Product</item>
                                <item name="status" xsi:type="string" translate="true">Item Status</item>
                                <!-- <item name="price-original" xsi:type="string" translate="true">Original Price</item> -->
                                <item name="price" xsi:type="string" translate="true">Price</item>
                                <item name="ordered-qty" xsi:type="string" translate="true">Qty</item>
                                <item name="subtotal" xsi:type="string" translate="true">Subtotal</item>
                                <item name="tax-amount" xsi:type="string" translate="true">Tax Amount</item>
                                <item name="tax-percent" xsi:type="string" translate="true">Tax Percent</item>
                                <item name="discont" xsi:type="string" translate="true">Discount Amount</item>
                                <item name="total" xsi:type="string" translate="true">Row Total</item>
                            </argument>
                        </arguments>
                        <block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" name="default_order_items_renderer" template="Magento_Sales::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>
                                </argument>
                            </arguments>
                        </block>
                        <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="Magento_Sales::items/column/qty.phtml" group="column"/>
                        <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="Magento_Sales::items/column/name.phtml" group="column"/>
                        <block class="Magento\Framework\View\Element\Text\ListText" name="order_item_extra_info"/>
                    </block>
Related Topic