Adding a New Column to Sales Order Order Elements in Magento Admin

In the Magento admin interface, I need to change the tables in the order of sale / order / view, so that it shows in addition to the names of the products and their manufacturer.

I am trying to find a file to modify for this to happen. I thought I would find a section with all the columns that appear in the application / code / kernel / Mage / Sales / Block / Order / Element / Renderer / Default.php, but when checking it, there seems to be no link to the columns / product attributes.

I also tried changing the application / design / adminhtml / default / default / template / sales / order / view / elements / visualizer / default.phtml changing

<?php echo $this->getColumnHtml($_item, 'name') ?>

in

<?php echo $this->getColumnHtml($_item, 'manufacturer') ?>

but nothing has changed, so I suppose this file is not involved ...

Can someone tell me the correct file to modify?

Thanks!

+4
source share
6 answers

After quite a bit of looking at the code and with some help from college, we found that the two files changed to add a column to this view:

  • app/design/adminhtml/default/default/template/sales/order/view/items.phtml to add a table title

  • app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml to populate the column with data.

I am not very versed in Magento, but I think that in order to do a "clean job", you should not directly modify these files, but instead redefine them.

EDIT

  • app/design/adminhtml/default/default/template/downloadable/sales/order/view/items/renderer/downloadable.phtml to populate the column with data for downloaded products.
+15
source

To add a table title: app/design/adminhtml/default/default/template/sales/order/view/items.phtml

app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml

These files are useful.

+2
source

To add a table title and its value, add the sales_order_view.xml layout to your theme or module with a new argument.

 <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" 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="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> <item name="repair" xsi:type="string" translate="true">Repair</item> </argument> </arguments> <block class="Namespace\Module\Block\Adminhtml\DefaultRenderer" as="default" 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> <item name="repair" xsi:type="string" translate="false">col-repair</item> </argument> </arguments> </block> </referenceBlock> </body> 

`I added a new column with a name correction. now you need to add a value for this column. so you need to override the file \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

+2
source

Administrative grids are managed by their block. For sale, this is the class Mage_Adminhtml_Block_Sales_Order_Grid

the modifying / overriding _prepareColumns () method should do the trick

+1
source

I don't have a magenta setting, but I have some ideas. Perhaps the column is not defined inside the template file (phtml), but inside the xml layout file. Just search in the layout / sales.xml file.

And you may not have disabled magento cache, so you are not seeing any changes.

0
source

All Articles