How can I join shipping and payment method to getCollection()?

Home / Uncategorized / How can I join shipping and payment method to getCollection()?

Question:
I have custom shipping and payment method (
SELECT * FROM `sales_flat_order` WHERE ‘shipping_method = custom_custom’
) and I have to joinLeft this methods to $this->getCollection() from sales_order(http://my-magento.local/index.php/admin/sales_order/) ( appdesignadminhtmldefaultdefaulttemplatewidgetgrid.phtml) to minimize query to db.
public function _addCustomFields()
{
$billingAliasName = ‘sfo’; //sales_flat_order
$joinTable = $this->getTable(‘sales/order’);
$select = $this->getSelect();
$select
->joinInner(
array($billingAliasName => $joinTable),
"(main_table.entity_id = {$billingAliasName}.increment_id" . " AND
{$billingAliasName}.shipping_method =
‘custom_custom’)" , array( $billingAliasName . ‘.shipping_method’
)
);
return $this;
}
and in appcodelocalMageAdminhtmlBlockSalesOrderGrid.php
protected function _prepareGrid()
{
parent::_prepareGrid();
$cls = new Mage_Sales_Model_Resource_Order_Collection;
$cls->_addCustomFields();
}
but it’s not work. Tell me pls what I did wrong? And how to correctly must doing this?


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *