2
Report -> Product -> Ordered

I want to add new column Brand (f_brand) in report grid.

I am unable to find any Grid.php or something like this file.

Can anyone help me on this? Which file I need to override and how can I add new column in this grid?

1

It looks like the columns of that report are created in the layout file reports_report_product_sold_grid.xml. You would need to add a file with this name in your own module (e.g. Company/ModuleName/view/adminhtml/layout/reports_report_product_sold_grid.xml) and add a new column block. Something like this

<block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.report.grid.columnSet.sku" as="sku">
    <arguments>
        <argument name="header" xsi:type="string" translate="true">SKU</argument>
        <argument name="type" xsi:type="string">text</argument>
        <argument name="index" xsi:type="string">order_items_sku</argument>
        <argument name="id" xsi:type="string">sku</argument>
        <argument name="column_css_class" xsi:type="string">col-sku</argument>
        <argument name="header_css_class" xsi:type="string">col-sku</argument>
    </arguments>
</block>

If you need custom functionality you could create a new Block that extends Magento\Backend\Block\Widget\Grid\Column.

  • Good one :) ... Lets say I have added new column with index brand_f how can I populate data in it? Many thanks for your support – Atif Ameer Feb 22 '19 at 14:22
  • 1
    You'll need to populate the collection with data in that index. My guess is most likely you will create a plugin on source/vendor/magento/module-reports/Model/ResourceModel/Product/Sold/Collection.php::addOrderedQty function and add your column as a join to the select. – rain2o Feb 22 '19 at 14:31

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.