1

I'm making a custom invoice grid. I want to add one column "expire date" which is in "sales_flat_order_payment". I retrieve the data but can't add it in the column. Someone knows what's wrong? Probably the join function is wrong.

class Mage_Adminhtml_Block_Sales_Invoice_Grid extends Mage_Adminhtml_Block_Widget_Grid {

protected function _prepareCollection() {
        $collection = Mage::getResourceModel($this->_getCollectionClass());
        $resource = Mage::getSingleton('core/resource');

        $items = Mage::getModel('sales/order_payment')->getCollection()->addAttributeToSelect('expire_date');
        //Holds expire date data
        Zend_Debug::dump($items->getData());

        //Something goes wrong here
        $collection->getSelect()->join('sales_flat_order_payment', 'main_table.entity_id = sales_flat_order_payment.parent_id', array('expire_date'));

        //Gives an error: Column not found: 1054 Unknown column 'sales_flat_order_payment.expire_date' in 'field list'
        Zend_Debug::dump($collection->getData());

        $this->setCollection($collection);
        return parent::_prepareCollection();
}

    protected function _prepareColumns(){

    $this->addColumn('expire_date', array(
                'header'    => Mage::helper('payment')->__('ExpireDate'),
                'index'     => 'expire_date',
                'type'      => 'datetime',
            ));

    }
}
  • here $this->_getCollectionClass() means which class? – Abhilash Acharya Jul 1 '15 at 13:44
  • It is in this class: class Mage_Adminhtml_Block_Sales_Invoice_Grid extends Mage_Adminhtml_Block_Widget_Grid { – D_RBD Jul 1 '15 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.