public function fillRecommendationColumn(Varien_Event_Observer $evt) { $resource = Mage::getSingleton('core/resource'); $tabel_nam = $resource->getTableName('score/score'); $collection = $evt->getOrderGridCollection(); $collection->getSelect()->joinLeft($tabel_nam . ' as score', 'main_table.entity_id = score.order_no'); }
/** * Join columns to the Orders Collection. * * @param Varien_Event_Observer $observer */ public function modifyOrderCollection($observer) { $permissibleActions = array('index', 'grid', 'exportCsv', 'exportExcel'); if (false === strpos(Mage::app()->getRequest()->getControllerName(), 'sales_order') || !in_array(Mage::app()->getRequest()->getActionName(), $permissibleActions)) { return; } $collection = $observer->getOrderGridCollection(); $tableNameCustomerEntity = Mage::getSingleton('core/resource')->getTableName('customer_entity'); $tableNameGuestEntity = Mage::getSingleton('core/resource')->getTableName('amcustomerattr/guest'); $attributesCollection = Mage::getModel('customer/attribute')->getCollection(); $filters = array("is_user_defined = 1", "attribute_code != 'customer_activated'"); $attributesCollection = Mage::helper('amcustomerattr')->addFilters($attributesCollection, 'eav_attribute', $filters); $filters = array("used_in_order_grid = 1"); $attributesCollection = Mage::helper('amcustomerattr')->addFilters($attributesCollection, 'customer_eav_attribute', $filters); if ($attributesCollection->getSize() > 0) { foreach ($attributesCollection as $attribute) { if ($this->_isJoined($collection->getSelect()->getPart('from'), '_table_' . $attribute->getAttributeCode())) { continue; } $collection->getSelect()->joinLeft(array('_table_' . $attribute->getAttributeCode() => $tableNameCustomerEntity . "_" . $attribute->getBackendType()), "_table_" . $attribute->getAttributeCode() . ".entity_id = main_table.customer_id " . " AND _table_" . $attribute->getAttributeCode() . ".attribute_id = " . $attribute->getAttributeId(), array($attribute->getAttributeCode() => "COALESCE(`_table_" . $attribute->getAttributeCode() . "`.`value`," . "`_table_guest_" . $attribute->getAttributeCode() . "`.`" . $attribute->getAttributeCode() . "`)"))->joinLeft(array("_table_guest_" . $attribute->getAttributeCode() => $tableNameGuestEntity), "_table_guest_" . $attribute->getAttributeCode() . ".order_id = main_table.entity_id", array()); } } }
/** * Join columns to the Orders Collection. * @param Varien_Event_Observer $observer */ public function modifyOrderCollection($observer) { $permissibleActions = array('index', 'grid'); if (false === strpos(Mage::app()->getRequest()->getControllerName(), 'sales_order') || !in_array(Mage::app()->getRequest()->getActionName(), $permissibleActions)) { return; } $collection = $observer->getOrderGridCollection(); $tableNameCustomerEntity = Mage::getSingleton('core/resource')->getTableName('customer_entity'); $attributesCollection = Mage::getModel('customer/attribute')->getCollection(); $alias = Mage::helper('amcustomerattr')->getProperAlias($attributesCollection->getSelect()->getPart('from'), 'eav_attribute'); $attributesCollection->getSelect()->where($alias . 'is_user_defined = ?', 1)->where($alias . 'attribute_code != ?', 'customer_activated'); $alias = Mage::helper('amcustomerattr')->getProperAlias($attributesCollection->getSelect()->getPart('from'), 'customer_eav_attribute'); $attributesCollection->getSelect()->where($alias . 'used_in_order_grid = ?', 1); if ($attributesCollection->getSize() > 0) { foreach ($attributesCollection as $attribute) { if ($this->_isJoined($collection->getSelect()->getPart('from'), '_table_' . $attribute->getAttributeCode())) { continue; } $collection->getSelect()->joinLeft(array('_table_' . $attribute->getAttributeCode() => $tableNameCustomerEntity . '_' . $attribute->getBackendType()), '_table_' . $attribute->getAttributeCode() . '.entity_id = main_table.customer_id ' . ' AND _table_' . $attribute->getAttributeCode() . '.attribute_id = ' . $attribute->getAttributeId(), array($attribute->getAttributeCode() => '_table_' . $attribute->getAttributeCode() . '.value')); } } }