Question

How can I add a SKU column in the Best Seller Product Report.

Was it helpful?

Solution

Step 1: Copy the below file:

app/code/core/Mage/Adminhtml/Block/Report/Sales/Bestsellers/Grid.php

to

app/code/local/Mage/Adminhtml/Block/Report/Sales/Bestsellers/Grid.php

and add the following code:

$this->addColumn('product_sku', array(
    'header'    => Mage::helper('sales')->__('Sku'),
    'index'     => 'product_id',
    'type'      => 'string',
    'sortable'  => false,
    'renderer'      => 'Mage_Adminhtml_Block_Report_Sales_Bestsellers_Grid_Sku'
));

Step 2: Create one file with name Sku.php under below path

app/code/local/Mage/Adminhtml/Block/Report/Sales/Bestsellers/Grid/Sku.php

Add the following code to Sku.php

<?php
class Mage_Adminhtml_Block_Report_Sales_Bestsellers_Grid_Sku extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    public function render(Varien_Object $row) { 
        $productId =  $row->getData($this->getColumn()->getIndex());
        return Mage::getModel('catalog/product')->load($productId)->getSku();
    }
}

Clear the cache if you have enabled.

Thats it!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top