0

I've successfully managed to create a custom report module in Magento following the (sort of) guide here Creating new completely custom reports

enter image description here

I have tried to add 6 columns to the report but it seems to be limited somewhere to only display 4 (both on the front end and csv export). If I remove some columns, the other ones show so they have been created corretly. Here's my grid;

class Juicy_Taxreport_Block_Adminhtml_Taxreport_Grid extends Mage_Adminhtml_Block_Report_Grid
{

    public function __construct() {
        parent::__construct();
        $this->setId('taxreportGrid');
        $this->setDefaultSort('created_at');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);
        $this->setSubReportSize(false);
    }

    protected function _prepareCollection() {
        parent::_prepareCollection();
        $this->getCollection()->initReport('taxreport/taxreport');
        return $this;
    }

    protected function _prepareColumns() {
        $this->addColumn('ordered_qty', array(
            'header'    =>Mage::helper('reports')->__('Quantity Ordered'),
            'align'     =>'right',
            'index'     =>'qty_ordered'
        ));
        $this->addColumn('item_id', array(
            'header' => Mage::helper('taxreport')->__('Item ID'),
            'align' => 'right',
            'index' => 'item_id'
        ));
        $this->addColumn('store_id', array(
            'header' => Mage::helper('taxreport')->__('Price'),
            'align' => 'right',
            'index' => 'base_original_price'
        ));
        $this->addColumn('store_id', array(
            'header' => Mage::helper('taxreport')->__('Tax Percent'),
            'align' => 'right',
            'index' => 'base_original_price'
        ));
        $this->addColumn('store_id', array(
            'header' => Mage::helper('taxreport')->__('Tax Amount'),
            'align' => 'right',
            'index' => 'tax_amount'
        ));
        $this->addColumn('store_id', array(
            'header' => Mage::helper('taxreport')->__('Tax Amount'),
            'align' => 'right',
            'index' => 'tax_amount'
        ));
        $this->addExportType('*/*/exportCsv', Mage::helper('taxreport')->__('CSV'));
        $this->addExportType('*/*/exportXml', Mage::helper('taxreport')->__('XML'));
        return parent::_prepareColumns();
    }

    public function getRowUrl($row) {
        return false;
    }

    public function getReport($from, $to) {
        if ($from == '') {
            $from = $this->getFilter('report_from');
        }
        if ($to == '') {
            $to = $this->getFilter('report_to');
        }


        return $this->getCollection()->getReport($from, $to);
    }
}

In the example above, I can only see one of the tax related columns. If I remove, for example, the quantity column then I see two tax related columns. I have tried sifting through the extended classes but I can't seem to find anything there.

1

Don't repeated store_id. You can created render for that.

$this->addColumn('store_id_1', array(
    'header' => Mage::helper('taxreport')->__('Price'),
    'align' => 'right',
    'index' => 'base_original_price'
));

$this->addColumn('store_id_2', array(
    'header' => Mage::helper('taxreport')->__('Tax Percent'),
    'align' => 'right',
    'index' => 'base_original_price'
));

$this->addColumn('store_id_3', array(
    'header' => Mage::helper('taxreport')->__('Tax Amount'),
    'align' => 'right',
    'index' => 'tax_amount'
));

$this->addColumn('store_id_4', array(
    'header' => Mage::helper('taxreport')->__('Tax Amount'),
    'align' => 'right',
    'index' => 'tax_amount'
));

like used custom

  • This is good advice, I'll try this and get back to You! – Lewis Jul 6 '17 at 16:30
  • ya sure. you are most welcome thanks this is my first correct answer i so happy. – Vijay Khirade Jul 6 '17 at 17:17

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.