简体   繁体   中英

Getting Payment Method into Report in Magento

I am using the dropship module ( Unirgy_Dropship_Block_Adminhtml_Report_Grid ) and I'm trying to add the payment method as a column. I was able to locate the table I needed and add it to the collection. Problem is that the fields are populated with nulls. Any idea? This is my basic code: The line that needs fixing is the joinLeft line where I'm adding the method attribute.

protected function _prepareCollection() {
    //...
    $eav = Mage::getSingleton('eav/config');
    $oapAttr = $eav->getAttribute('order_payment', 'method');
    $collection = Mage::getResourceModel('sales/order_shipment_collection');
    //...
    $collection->getSelect()
        ->join(array('oa'=>Mage::getSingleton('core/resource')->getTableName('sales_order_entity')), 'oa.parent_id=_table_order_increment_id.entity_id', array())
        ->joinLeft(array('oap'=>Mage::getSingleton('core/resource')->getTableName('sales_order_entity_varchar')), "oap.entity_id=oa.entity_id and oap.attribute_id=".$oapAttr->getId(), array('method'=>'value'))
    ;
    $this->setCollection($collection);
    //...
    return parent::_prepareCollection();
}
protected function _prepareColumns() {
    //...
    $this->addColumn('method', array(
        'header'  => $hlp->__('Payment Method'),
        'index'   => 'method',
        'type'    => 'options',
        'options' => array(
            'authorizenet'    => "Credit Card",
            'paypal_standard' => "Paypal",
            'ugiftcert'       => "Gift Certificate",
            'free'            => "Free",
        )
    ));
    //...
}

The second post on this link helped me hugely when I did something similar

http://www.magentocommerce.com/boards/viewthread/192232/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM