Esempio n. 1
0
 /**
  * Init collection select
  *
  * @return Mage_Core_Model_Resource_Db_Collection_Abstract
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     // Join order comment
     $this->getSelect()->joinLeft(array('ordercomment_table' => $this->getTable('sales/order_status_history')), 'main_table.entity_id = ordercomment_table.parent_id AND ordercomment_table.comment IS NOT NULL', array('ordercomment' => 'ordercomment_table.comment'))->group('main_table.entity_id');
     return $this;
 }
Esempio n. 2
0
 public function __construct($resource = null)
 {
     parent::__construct();
     if (Mage::helper('tweaks')->isOrderViewProductsColumnBackendEnable()) {
         $this->setFieldProductNames();
         $this->setShellRequest();
     }
 }
 public function _afterLoad()
 {
     foreach ($this as $object) {
         $order_id = $object->getEntityId();
         $sales_flat_order_item = $this->getTable('sales/order_item');
         $adapter = $this->getResource()->getReadConnection();
         $select = $adapter->select()->from($sales_flat_order_item, array('sku'))->where("order_id = {$order_id} and parent_item_id IS NULL");
         $rows = $adapter->fetchAll($select);
         $skus = '';
         foreach ($rows as $row) {
             $skus .= $row['sku'] . ',';
         }
         $skus = substr($skus, 0, -1);
         $object->setSkus($skus);
     }
     return parent::_afterLoad();
 }
 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;
 }
 public function getSelectCountSql()
 {
     if ($this->_isGroupSql) {
         $this->_renderFilters();
         $countSelect = clone $this->getSelect();
         $countSelect->reset(Zend_Db_Select::ORDER);
         $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
         $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
         $countSelect->reset(Zend_Db_Select::COLUMNS);
         if (count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
             $countSelect->reset(Zend_Db_Select::GROUP);
             $countSelect->distinct(true);
             $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
             $countSelect->columns("COUNT(DISTINCT " . implode(", ", $group) . ")");
         } else {
             $countSelect->columns('COUNT(*)');
         }
         return $countSelect;
     }
     return parent::getSelectCountSql();
 }
 /**
  * Init collection count select
  *
  * @return Varien_Db_Select
  */
 public function getSelectCountSql()
 {
     return parent::getSelectCountSql()->reset(Zend_Db_Select::GROUP);
 }
Esempio n. 7
0
 protected function _construct()
 {
     parent::_construct();
     $this->setMainTable('enterprise_salesarchive/order_grid');
 }