मैं Magento संस्करण 1.4 के साथ काम कर रहा हूं और मैंने बिक्री ऑर्डर ग्रिड में अतिरिक्त ग्रिड कॉलम (नाम और स्कस) जोड़ा है, लौटाया गया डेटा सही है लेकिन मैं ' मीटर पृष्ठांकन और अभिलेखों की कुल संख्या, इस प्रकार मेरी कोड के साथ समस्या हो:मैगेंटो सेल्स ऑर्डर ग्रिड नाम और स्कस कॉलम जोड़े गए रिकॉर्ड की गलत संख्या दिखाता है
सबसे पहले मैं संपादित Mage_Adminhtml_Block_Sales_Order_Grid
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ", ")'),
'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ", ")'),
)
);
$collection->getSelect()->group('entity_id');
$this->setCollection($collection);
return parent::_prepareCollection();
}
तब मैं सही परिणाम देने के लिए इस विधि को ओवरराइड जब नामों से फिल्टर या SKUs
protected function _addColumnFilterToCollection($column)
{
if($this->getCollection() && $column->getFilter()->getValue())
{
if($column->getId() == 'skus'){
$this->getCollection()->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ", ")'),
)
)->getSelect()
->having('find_in_set(?, skus)', $column->getFilter()->getValue());
return $this;
}
if($column->getId() == 'names'){
$this->getCollection()->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ", ")'),
)
)->getSelect()
->having('find_in_set(?, names)', $column->getFilter()->getValue());
return $this;
}
}
return parent::_addColumnFilterToCollection($column);
}
तब मैं Mage_Sales_Model_Mysql4_Order_Collection वर्ग
public function getSelectCountSql()
{
$countSelect = parent::getSelectCountSql();
//added
$countSelect->reset(Zend_Db_Select::HAVING);
//end
$countSelect->resetJoinLeft();
return $countSelect;
}
कोई आइडिया कैसे मैं पंक्तियों की संख्या की गणना कर सकते में इस विधि getSelectCountSql() संपादित? अग्रिम में धन्यवाद।
जेम्स ' समाधान निश्चित रूप से बेहतर है, Meabed की getSize के पुनर्लेखन बाध्यकारी के नुकसान को ट्रिगर कर सकते हैं। मैंने एक "समूह द्वारा" खंड के साथ एक जटिल संग्रह लागू किया और "गिनती = 1" बग से मुलाकात की। '$ CountSelect-> रीसेट (Zend_Db_Select :: GROUP) जोड़ना; 'प्राप्त करने के लिए चयन करें CountSql ने एक साफ तरीके से चाल की है। – SMASHED