1

I want display sku at products ordered reports page, how can i get sku ?

enter image description here

  • u want sku column on grid – Arshad Muhammad Dec 3 '16 at 9:42
  • yes... found solution,, below – Gem Dec 3 '16 at 10:02
  • it not proper way to add sku you want extend to core block you own module – Arshad Muhammad Dec 3 '16 at 10:06
  • @ArshadMuhammad please don't confuse people. Your method is considered as good practice. – Gopal Patel Dec 3 '16 at 10:17
  • thanks @GopalPatel i don't confuse people just to share my knowledge – Arshad Muhammad Dec 3 '16 at 10:46
4

open app\code\core\Mage\Adminhtml\Block\Report\Product\Sold\Grid.php and put the below code in _prepareColumns() function

You can move Grid.php in your local folder as well or can override it in custom module.

$this->addColumn('sku', array(
    'header'    => Mage::helper('reports')->__('Product Sku'),
    'index'     =>'sku'
));
  • 3
    better to avoid edits on core files. – Mujahidh Jan 6 '17 at 10:12
  • this code is working only for simple products for me, do you have option for configurable? – Alam Zaib Dec 17 '18 at 13:52
6

You should rewrite magento core block Mage_Adminhtml_Block_Report_Product_Sold_Grid, here is the solution:

<blocks>
    <adminhtml>
        <rewrite>
            <report_product_sold_grid>Namespace_Module_Block_Adminhtml_Order_Grid</report_product_sold_grid>
        </rewrite>
    </adminhtml>
</blocks>

and extend in your moduel:

class Namespace_Module_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Block_Report_Product_Sold_Grid
{

    public function _prepareColumns()
    {
        $this->addColumn('sku', array(
            'header' => Mage::helper('reports')->__('Product Sku'),
            'index' => 'sku'
        ));
        parent::_prepareColumns();
    }
}
  • But its working – Gem Dec 3 '16 at 10:12
  • i.imgur.com/n5na90K.png – Gem Dec 3 '16 at 10:13
  • Does right what i did... – Gem Dec 3 '16 at 10:14
  • 1
    @JeevaRathinam yes it is right. His point is to override the grid in custom module which is good practice – Gopal Patel Dec 3 '16 at 10:15
  • u can override hole methode you own function just comment parent::_prepareColumns(); – Arshad Muhammad Dec 3 '16 at 10:18
0

The best solution is to create an extension for this functionality or just use mine

Magento 1.x Simple Products Report Extension

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.