cancel
Showing results for 
Search instead for 
Did you mean: 

add weight column to items ordered admin magento 2.3

add weight column to items ordered admin magento 2.3

11.PNG

Hello

I am going nuts here so please help clever people!

 

This is what I have done:

1. app/code/Dottie/Admin/view/adminhtml/templates/weight.phtml<span>Item Weight: <?php /* @escapeNotVerified */ echo number_format($_item->getWeight(), 2); ?>gm</span>

 

2. app/code/Dottie/Admin/view/adminhtml/layout/sales_order_view.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="order_items">
<arguments>
<argument name="columns" xsi:type="array">
<item name="weight_column" xsi:type="string" translate="true">Weight Column</item>
</argument>
</arguments>
<referenceBlock name="default_order_items_renderer">
<arguments>
<argument name="columns" xsi:type="array">
<item name="weight_column" xsi:type="string" translate="true">col-weight_column</item>
</argument>
</arguments>
</referenceBlock>

<block class="Magento\Sales\Block\Adminhtml\Order\View\Items" name="order_items"
template="Dottie_Admin::weight.phtml" group="column" />
</referenceBlock>
</body>

 

3. upgraded/decomp/cleared

 

Result....nothing Smiley Sad

 

 

What on earth have i done wrong or not enough? Please help

 

 

 

 

 

4 REPLIES 4

Re: add weight column to items ordered admin magento 2.3

You have an issue with `app/code/Dottie/Admin/view/adminhtml/layout/sales_order_view.xml`

 

and the file code should be like this:

 

<?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="columns" xsi:type="array">
<item name="weight" xsi:type="string" translate="true">weight</item>
</argument>
</arguments>

<block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn"
name="column_weight" template="Dottie_Admin::.phtml" group="column"/>
</referenceBlock>
<referenceBlock name="default_order_items_renderer">
<arguments>
<argument name="columns" xsi:type="array">
<item name="weight" xsi:type="string" translate="false">col-weight</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
 

 

As  Column name is `weight`  name="weight"  that block name is `column_weight`

 

that why 

Re: add weight column to items ordered admin magento 2.3

I'm also figuring out the same issue upsers

Re: add weight column to items ordered admin magento 2.3

Hello

Thank You for your time and reply. 

Unfortunately it is not working Smiley Sad

 

I can add the weight modifying core files...but this is not the way Smiley Sad

 

Why is the column not being added Smiley Sad

Re: add weight column to items ordered admin magento 2.3

Edit on core file is not right way. Your code will remove when you update magento version.