public function testAfterCommitCallbackOrderGridNotInvoked() { $adapter = Mage::getResourceSingleton('Mage_Core_Model_Resource')->getConnection('write'); $this->assertEquals(0, $adapter->getTransactionLevel(), 'This test must be outside a transaction.'); $localOrderModel = new Mage_Sales_Model_Order(); $resource = $localOrderModel->getResource(); $resource->beginTransaction(); try { /** @var $order Mage_Sales_Model_Order */ require __DIR__ . '/../_files/order.php'; $collection = new Mage_Sales_Model_Resource_Order_Grid_Collection(); $this->assertEquals(0, $collection->count()); $resource->rollBack(); } catch (Exception $e) { $resource->rollBack(); throw $e; } }
/** * Minimize usual count select * @return Varien_Db_Select */ public function getSelectCountSql() { $controller_name = Mage::app()->getRequest()->getControllerName(); if ($controller_name == 'sales_order' || $controller_name == 'sales_archive') { $this->_renderFilters(); $unionSelect = clone $this->getSelect(); $unionSelect->reset(Zend_Db_Select::ORDER); $unionSelect->reset(Zend_Db_Select::LIMIT_COUNT); $unionSelect->reset(Zend_Db_Select::LIMIT_OFFSET); $countSelect = clone $this->getSelect(); $countSelect->reset(); $countSelect->from(array('a' => $unionSelect), 'COUNT(*)'); } else { $countSelect = parent::getSelectCountSql(); } return $countSelect; }
/** * Modify collection after load * * @return Mage_Core_Model_Resource_Db_Collection_Abstract */ protected function _afterLoad() { parent::_afterLoad(); if (count($this->_items) > 0) { $ids = array(); foreach ($this->_items as $item) { $ids[] = $item->getId(); } $ids = implode(',', $ids); $select = $this->getConnection()->select()->from($this->getTable('sales/order_status_history'))->where("parent_id IN ({$ids})")->order('created_at ASC'); $items = $this->getConnection()->fetchAll($select); foreach ($items as $item) { $parent = $this->_items[$item['parent_id']]; $parent->setOrdercomment($item['comment']); } } return $this; }
/** * Collection initialization * */ protected function _construct() { parent::_construct(); $this->setMainTable('enterprise_salesarchive/order_grid'); }
/** * Model initialization * */ protected function _construct() { parent::_construct(); $this->setMainTable('buyback/order_grid'); }
/** * Init select * @return Mage_Core_Model_Resource_Db_Collection_Abstract */ protected function _initSelect() { $this->addFilterToMap('store_id', 'main_table.store_id')->addFilterToMap('created_at', 'main_table.created_at')->addFilterToMap('updated_at', 'main_table.updated_at'); return parent::_initSelect(); }