2

I'm looking to create a custom Magento Adminhtml report based on the Products Sold report (Reports->Products->Products Ordered in Adminhtml). I can see that the Products Sold report's Grid Block is Mage_Adminhtml_Block_Report_Product_Sold_Grid.

However, I'm obviously missing something, because the report has a period column, which isn't added to the report in the Grid block's _prepareColumns() function. Here are the other two columns being added in Mage_Adminhtml_Block_Report_Product_Sold_Grid:

protected function _prepareColumns()
{
    $this->addColumn('name', array(
        'header'    =>Mage::helper('reports')->__('Product Name'),
        'index'     =>'order_items_name'
    ));

    $this->addColumn('ordered_qty', array(
        'header'    =>Mage::helper('reports')->__('Quantity Ordered'),
        'width'     =>'120px',
        'align'     =>'right',
        'index'     =>'ordered_qty',
        'total'     =>'sum',
        'type'      =>'number'
    ));

    $this->addExportType('*/*/exportSoldCsv', Mage::helper('reports')->__('CSV'));
    $this->addExportType('*/*/exportSoldExcel', Mage::helper('reports')->__('Excel XML'));

    return parent::_prepareColumns();
}

My question is where is the Period column is coming from, and from where is it getting its data?

1 Answer 1

1

Take a look at adminhtml/default/default/template/report/grid.phtml.
On line 136(Magento 1.7.0.2) the following statement starts a loop which outputs the individual rows: getCollection()->getIntervals() as $_index => $_item): ?>.
The $_index variable holds the time information. Than take a look at the parent class of Mage_Adminhtml_Block_Report_Product_Sold_Grid - Mage_Adminhtml_Block_Report_Grid.
On line 147 the following statement sets the time span of the report: $collection->setInterval($from, $to). Hope that this will help you! Regards

1
  • Thanks - sometimes it's hard to see the wood for the trees!
    – Rob L
    Mar 30, 2014 at 10:24

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.