Exemplo n.º 1
0
 public function getSelectCountSql()
 {
     /* @var $countSelect Varien_Db_Select */
     $countSelect = parent::getSelectCountSql();
     $countSelect->resetJoinLeft();
     $countSelect->reset(Zend_Db_Select::GROUP);
     // add this to reset the GROUP
     return $countSelect;
 }
Exemplo n.º 2
0
 /**
  * Returns order collection with some filters
  * @return Mage_Sales_Order_Collection
  */
 public function getCustomerOrders()
 {
     if (!is_null($this->_customerOrders)) {
         return $this->_customerOrders;
     }
     if ($this->getGuestMode()) {
         $this->_customerOrders = array($this->_getSession()->getData('awrma_guest_order'));
     } else {
         $this->_customerOrders = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('customer_id', $this->_getSession()->getCustomer()->getId())->addFieldToFilter('state', array('in' => array('complete')))->setOrder('created_at', 'desc');
         $this->_customerOrders->getSelect()->where('updated_at > DATE_SUB(NOW(), INTERVAL ? DAY)', Mage::helper('awrma/config')->getDaysAfter());
         $this->_customerOrders->load();
     }
     return $this->_customerOrders;
 }
Exemplo n.º 3
0
 /**
  * Render related orders grid information
  */
 public function prepareRelatedOrdersFrontendGrid()
 {
     $this->_prepareRelatedOrders(array('increment_id', 'created_at', 'customer_firstname', 'customer_middlename', 'customer_lastname', 'base_grand_total', 'status'));
     $this->_relatedOrders->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()));
     $pager = $this->getLayout()->createBlock('page/html_pager')->setCollection($this->_relatedOrders)->setIsOutputRequired(false);
     $this->setChild('pager', $pager);
     $this->setGridColumns(array(new Varien_Object(array('index' => 'increment_id', 'title' => $this->__('Order #'), 'is_nobr' => true, 'width' => 1)), new Varien_Object(array('index' => 'created_at', 'title' => $this->__('Date'), 'is_nobr' => true, 'width' => 1)), new Varien_Object(array('index' => 'customer_name', 'title' => $this->__('Customer Name'))), new Varien_Object(array('index' => 'base_grand_total', 'title' => $this->__('Order Total'), 'is_nobr' => true, 'width' => 1, 'is_amount' => true)), new Varien_Object(array('index' => 'status', 'title' => $this->__('Order Status'), 'is_nobr' => true, 'width' => 1))));
     $orders = array();
     foreach ($this->_relatedOrders as $order) {
         $orders[] = new Varien_Object(array('increment_id' => $order->getIncrementId(), 'created_at' => $this->formatDate($order->getCreatedAt()), 'customer_name' => $order->getCustomerName(), 'base_grand_total' => Mage::helper('core')->formatCurrency($order->getBaseGrandTotal(), false), 'status' => $order->getStatusLabel(), 'increment_id_link_url' => $this->getUrl('sales/order/view/', array('order_id' => $order->getId()))));
     }
     if ($orders) {
         $this->setGridElements($orders);
     }
 }
 /**
  * Before load action
  *
  * @return Varien_Data_Collection_Db
  */
 protected function _beforeLoad()
 {
     parent::_beforeLoad();
     if ($this->_helper()->checkCatalogPermissionsActive()) {
         $wherePart = $this->getSelect()->getPart(Zend_Db_Select::SQL_WHERE);
         $this->getSelect()->reset(Zend_Db_Select::WHERE);
         $weHaveStoreId = false;
         foreach ($wherePart as $where) {
             if (strpos($where, "store_id") !== false) {
                 if (!$weHaveStoreId) {
                     if ($this->_helper()->getNeedMainTableAlias()) {
                         $this->getSelect()->where(str_replace("AND ", "", str_replace("(store_id", "(main_table.store_id", $where)));
                     } else {
                         $this->getSelect()->where(str_replace("AND ", "", str_replace("(store_id", "(e.store_id", $where)));
                     }
                     $weHaveStoreId = true;
                 }
             } else {
                 $this->getSelect()->where(str_replace("AND ", "", $where));
             }
         }
     }
     return $this;
 }
Exemplo n.º 5
0
 protected function _construct()
 {
     parent::_construct();
     $this->setMainTable('sales/order_grid');
 }
Exemplo n.º 6
0
 public function getSelectCountSql()
 {
     $countSelect = parent::getSelectCountSql();
     $countSelect->reset(Zend_Db_Select::GROUP);
     return $countSelect;
 }