我需要使用自定义表将联接添加到我的订单集合中。
为此,我使用以下代码:
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()
->joinLeft(array(
"t1" => 'fp_sellecrcommision_data'),
"main_table.increment_id = t1.store_order_id",
array("commiisiion_status" => "t1.commiisiion_status")
);
$collection->addFieldToFilter("store_id",$storeid )
->addAttributeToFilter("status","complete");
哪个工作正常。但是当我应用过滤器时,它抛出以下错误SQLSTATE[42S22]: Column not found: 1054 Unknown column 'commiisiion_status' in 'where clause', query was: SELECT COUNT(*) FROM `sales_flat_order_grid` AS `main_table` WHERE (`store_id` = '1') AND (`status` = 'complete') AND (`commiisiion_status` = '0')
这是我的自定义表的结构:下面是我在网格中的自定义列:
$this->addColumn('commiisiion_status', array(
'header' => Mage::helper('sellercommision')->__('Commision Status'),
'index' => 'commiisiion_status',
'type' => 'options',
'options' => XYZ_Sellercommision_Block_Adminhtml_Sellercommision_Storeorders::commisionsStatusesArray(),
));
我怎样才能解决这个问题? 最佳答案
嗨,我已经通过使用下面的_commissionFilterCallBack函数解决了此问题
protected function _commissionFilterCallBack($collection, $column)
{
//Put your logic here..!!
$value = $column->getFilter()->getValue();
$comission_paid_orders = array();
$commissionstatus_model = Mage::getModel("commissionstatus/commissionstatus")->getCollection();
foreach($commissionstatus_model as $commissionstatus){
$comission_paid_orders[] = $commissionstatus['order_imcrement_id'];
}
if ($value=="pending")
{
if(count($comission_paid_orders)==0){
return $this;
}
else{
$this->getCollection()->addAttributeToFilter("increment_id",array("nin"=>$comission_paid_orders));
return $this;
}
}
$this->getCollection()->getSelect()->where("t1.commission_status like ?", "%$value%");
return $this;
}
关于magento - 在Magento中过滤网格集合时,左联接引发错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40466078/