protected function _initSelect() { parent::_initSelect(); $modelCat = Mage::getResourceSingleton('downloads/categories'); $this->getSelect()->joinLeft(array('relation' => $this->getTable('downloads/relation')), 'main_table.file_id = relation.file_id', array('products_count' => 'COUNT(relation.product_id)'))->joinLeft(array('cat' => $modelCat->getMainTable()), 'main_table.category_id = cat.category_id', array('title'))->group('main_table.file_id'); return $this; }
public function _initSelect() { //die("<PRE>".$this->getSelect()->__toString(). "</PRE>"); parent::_initSelect(); $this->getSelect()->distinct(true)->joinInner(array('product_table' => $this->getTable('catalogrule/rule_product')), 'main_table.rule_id = product_table.rule_id', array())->where('from_time=0 or from_time<=? or to_time=0 or to_time>=?', now())->group('main_table.rule_id'); //die("<PRE>".$this->getSelect()->__toString()."</PRE>"); }
protected function _initSelect() { parent::_initSelect(); // $this->getSelect()->where('main_table.post_type=?', 'post') // ->where('main_table.post_status=?', 'publish'); return $this; }
protected function _initSelect() { parent::_initSelect(); $select = $this->getSelect(); $select->join(array('cust' => $this->getTable('loyaltyprogram/customer_entity')), 'referer_id = cust.entity_id'); return $this; }
/** * * * (overrides parent method) */ public function _initSelect() { parent::_initSelect(); // Add a simplified version of the transfer references (1 reference per 1 transfer) $this->_addTransferReferences($this->_getSingleReferenceSelect()); return $this; }
protected function _initSelect() { parent::_initSelect(); $this->getSelect()->joinLeft(array('cat' => $this->getIndex()->getProperty('db_table_prefix') . 'categories'), 'cat.id=main_table.catid', array('path')); // echo $this->getSelect();die(); return $this; }
public function addListRestriction() { $statuses = Mage::getStoreConfig('rewardpoints/default/valid_statuses', Mage::app()->getStore()->getId()); $statuses_used = Mage::getStoreConfig('rewardpoints/default/valid_used_statuses', Mage::app()->getStore()->getId()); $status_field = Mage::getStoreConfig('rewardpoints/default/status_used', Mage::app()->getStore()->getId()); $order_states = explode(",", $statuses); $order_states_used = explode(",", $statuses_used); parent::_initSelect(); $select = $this->getSelect(); $select->from($this->getTable('rewardpoints/rewardpoints_account'), array(new Zend_Db_Expr('SUM(' . $this->getTable('rewardpoints/rewardpoints_account') . '.points_current) AS all_points_accumulated'), new Zend_Db_Expr('SUM(' . $this->getTable('rewardpoints/rewardpoints_account') . '.points_spent) AS all_points_spent')))->where($this->getTable('rewardpoints/rewardpoints_account') . '.customer_id = e.entity_id'); if (version_compare(Mage::getVersion(), '1.4.0', '>=')) { /*$select->where(" (".Mage::getModel("rewardpoints/stats")->constructSqlPointsType($this->getTable('rewardpoints/rewardpoints_account'))." or ".$this->getTable('rewardpoints/rewardpoints_account').".rewardpoints_$status_field in (?) ) ", $order_states);*/ $select->where(" (" . Mage::getModel("rewardpoints/stats")->constructSqlPointsType($this->getTable('rewardpoints/rewardpoints_account')) . "\n or (" . $this->getTable('rewardpoints/rewardpoints_account') . ".rewardpoints_{$status_field} in (?) AND " . $this->getTable('rewardpoints/rewardpoints_account') . ".points_current > 0)\n or (" . $this->getTable('rewardpoints/rewardpoints_account') . ".rewardpoints_{$status_field} in (?) AND " . $this->getTable('rewardpoints/rewardpoints_account') . ".points_spent > 0)\n ) ", $order_states, $order_states_used); } else { /*$select->where(" (".Mage::getModel("rewardpoints/stats")->constructSqlPointsType($this->getTable('rewardpoints/rewardpoints_account'))." or ".$this->getTable('rewardpoints/rewardpoints_account').".rewardpoints_state in ((?) ) ", $order_states);*/ $select->where(" (" . Mage::getModel("rewardpoints/stats")->constructSqlPointsType($this->getTable('rewardpoints/rewardpoints_account')) . "\n or (" . $this->getTable('rewardpoints/rewardpoints_account') . ".rewardpoints_{$status_field} in (?) AND " . $this->getTable('rewardpoints/rewardpoints_account') . ".points_current > 0)\n or (" . $this->getTable('rewardpoints/rewardpoints_account') . ".rewardpoints_{$status_field} in (?) AND " . $this->getTable('rewardpoints/rewardpoints_account') . ".points_spent > 0)\n ) ", $order_states, $order_states_used); } //v.2.0.0 if (Mage::getStoreConfig('rewardpoints/default/points_delay', Mage::app()->getStore()->getId())) { $this->getSelect()->where('( NOW() >= ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_start OR ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_start IS NULL)'); } if (Mage::getStoreConfig('rewardpoints/default/points_duration', Mage::app()->getStore()->getId())) { $select->where('( ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_end >= NOW() OR ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_end IS NULL)'); } $select->group($this->getTable('rewardpoints/rewardpoints_account') . '.customer_id'); return $this; }
protected function _initSelect() { parent::_initSelect(); $select = $this->getSelect(); $select->join(array('cust' => $this->getTable('rewardpoints/customer_entity')), 'rewardpoints_referral_parent_id = cust.entity_id'); return $this; }
protected function _initSelect() { $allowedAttributes = explode(',', Mage::getStoreConfig('dc_catalog/attributes/selectedattributes')); parent::_initSelect(); $this->getSelect()->joinRight(array('aov' => $this->getTable('eav/attribute_option_value')), 'aov.option_id = main_table.attribute_option_id AND aov.store_id = main_table.attribute_value_store_id', array('value_id', 'value', 'store_id', 'option_id'))->join(array('ao' => $this->getTable('eav/attribute_option')), 'ao.option_id = aov.option_id', array())->join(array('a' => $this->getTable('eav/attribute')), 'a.attribute_id = ao.attribute_id', array('attribute_code', 'frontend_label', 'concat(a.attribute_code, ao.option_id, \'store\', aov.store_id) as false_id'))->where('a.attribute_code IN (?)', $allowedAttributes)->where('SUBSTRING(aov.value,1,1) != \'-\'')->order('value'); return $this; }
/** * Initialize select, add country iso3 code and region name * * @return void */ public function _initSelect() { parent::_initSelect(); $this->_select->columns(array('shipping_price' => new Zend_Db_Expr("IF(main_table.markup_type = '1' OR main_table.markup_type = '2', IF(main_table.markup_type = '1',CONCAT(main_table.price, '%'), CONCAT(main_table.price,'+')), CONCAT(main_table.price,'#'))")))->joinLeft(array('country_table' => $this->_countryTable), 'country_table.country_id = main_table.dest_country_id', array('dest_country' => 'iso3_code'))->joinLeft(array('region_table' => $this->_regionTable), 'region_table.region_id = main_table.dest_region_id', array('dest_region' => 'code')); $this->addOrder('dest_country', self::SORT_ORDER_ASC); $this->addOrder('dest_region', self::SORT_ORDER_ASC); $this->addOrder('dest_zip', self::SORT_ORDER_ASC); }
/** * Initialize select, add country iso3 code and region name * * @return void */ public function _initSelect() { parent::_initSelect(); Zitec_TableRates_Model_Mysql4_Tablerate::prepareSelectColumns($this->_select); $this->_select->joinLeft(array('country_table' => $this->_countryTable), "country_table.country_id = main_table.{$this->_map['dest_country_id']}", array('dest_country' => 'iso2_code'))->joinLeft(array('region_table' => $this->_regionTable), "region_table.region_id = main_table.{$this->_map['dest_region_id']}", array('dest_region' => 'code', 'dest_region_name' => 'default_name')); $select = (string) $this->_select; $this->_getHelper()->log($select); }
/** * Initialize select, add country iso3 code and region name * * @return void */ public function _initSelect() { parent::_initSelect(); $this->_select->joinLeft(array('country_table' => $this->_countryTable), 'country_table.country_id = main_table.dest_country_id', array('dest_country' => 'iso3_code'))->joinLeft(array('region_table' => $this->_regionTable), 'region_table.region_id = main_table.dest_region_id', array('dest_region' => 'code')); $this->addOrder('dest_country', self::SORT_ORDER_ASC); $this->addOrder('dest_region', self::SORT_ORDER_ASC); $this->addOrder('dest_zip', self::SORT_ORDER_ASC); }
/** * Ensures that only posts and not pages are returned * WP stores posts and pages in the same DB table * */ protected function _initSelect() { parent::_initSelect(); $this->getSelect()->where("`main_table`.`post_type`=?", $this->_getPostType()); return $this; }
protected function _initSelect() { parent::_initSelect(); //$attributeId = Mage::getResourceSingleton('outofstocksubscription/info')->getAttributeId(); $this->getSelect()->join(array("cpe" => 'catalog_product_entity'), 'main_table.product_id=cpe.entity_id', array('sku' => 'cpe.sku')); //$this->getSelect()->join(array("cpev" => 'catalog_product_entity_varchar'), 'cpe.entity_id=cpev.entity_id', array('value'=>'cpev.value')); //$this->getSelect()->where("cpev.attribute_id=".$attributeId); //$this->getSelect()->group("con.ticket_id"); //$this->getSelect()->order("con.comment_date DESC"); //exit($this->getSelect()); }
public function addListRestriction() { $statuses = Mage::getStoreConfig('rewardpoints/default/valid_statuses', Mage::app()->getStore()->getId()); $status_field = Mage::getStoreConfig('rewardpoints/default/status_used', Mage::app()->getStore()->getId()); $order_states = explode(",", $statuses); parent::_initSelect(); $select = $this->getSelect(); $select->from($this->getTable('rewardpoints/rewardpoints_account'), array(new Zend_Db_Expr('SUM(' . $this->getTable('rewardpoints/rewardpoints_account') . '.points_current) AS all_points_accumulated'), new Zend_Db_Expr('SUM(' . $this->getTable('rewardpoints/rewardpoints_account') . '.points_spent) AS all_points_spent')))->where($this->getTable('rewardpoints/rewardpoints_account') . '.customer_id = e.entity_id'); if (version_compare(Mage::getVersion(), '1.4.0', '>=')) { $select->where(" (" . $this->getTable('rewardpoints/rewardpoints_account') . ".order_id = '" . Rewardpoints_Model_Stats::TYPE_POINTS_REVIEW . "' or '" . Rewardpoints_Model_Stats::TYPE_POINTS_ADMIN . "' or " . $this->getTable('rewardpoints/rewardpoints_account') . ".order_id = '" . Rewardpoints_Model_Stats::TYPE_POINTS_REGISTRATION . "'\n or " . $this->getTable('rewardpoints/rewardpoints_account') . ".order_id in (SELECT increment_id\n FROM " . $this->getTable('sales/order') . " AS orders\n WHERE orders.{$status_field} IN (?))\n ) ", $order_states); } else { $table_sales_order = $this->getTable('sales/order') . '_varchar'; $select->where(" (" . $this->getTable('rewardpoints/rewardpoints_account') . ".order_id = '" . Rewardpoints_Model_Stats::TYPE_POINTS_REVIEW . "' or '" . Rewardpoints_Model_Stats::TYPE_POINTS_ADMIN . "' or " . $this->getTable('rewardpoints/rewardpoints_account') . ".order_id = '" . Rewardpoints_Model_Stats::TYPE_POINTS_REGISTRATION . "'\n or " . $this->getTable('rewardpoints/rewardpoints_account') . ".order_id in (SELECT increment_id\n FROM " . $this->getTable('sales/order') . " AS orders\n WHERE orders.entity_id IN (\n SELECT order_state.entity_id\n FROM " . $table_sales_order . " AS order_state\n WHERE order_state.value <> 'canceled'\n AND order_state.value in (?))\n ) ) ", $order_states); } //v.2.0.0 if (Mage::getStoreConfig('rewardpoints/default/points_delay', Mage::app()->getStore()->getId())) { $this->getSelect()->where('( NOW() >= ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_start OR ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_start IS NULL)'); } if (Mage::getStoreConfig('rewardpoints/default/points_duration', Mage::app()->getStore()->getId())) { $select->where('( ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_end >= NOW() OR ' . $this->getTable('rewardpoints/rewardpoints_account') . '.date_end IS NULL)'); } $select->group($this->getTable('rewardpoints/rewardpoints_account') . '.customer_id'); return $this; }
protected function _initSelect() { $this->joinFields(); parent::_initSelect(); }
/** * Attaches flat data to collection * @return AW_Sarp_Model_Mysql4_Subscription_Collection */ protected function _initselect() { parent::_initSelect(); $this->getSelect()->joinLeft(array('f' => Mage::getResourceModel('helpdeskultimate/ticket_flat')->getMainTable()), 'f.ticket_id=main_table.id'); return $this; }
/** * Initialize select object * */ protected function _initSelect() { parent::_initSelect(); $this->getSelect()->join(array('default_label' => $this->getTable('eav/form_fieldset_label')), 'main_table.fieldset_id=default_label.fieldset_id AND default_label.store_id=0', array()); if ($this->getStoreId() == 0) { $this->getSelect()->columns('label', 'default_label'); } else { $this->getSelect()->joinLeft(array('store_label' => $this->getTable('eav/form_fieldset_label')), 'main_table.fieldset_id=store_label.fieldset_id AND store_label.store_id=' . (int) $this->getStoreId(), array('label' => new Zend_Db_Expr('IFNULL(store_label.label, default_label.label)'))); } }
protected function _initSelect() { parent::_initSelect(); $this->initFields(); }
protected function _initSelect() { parent::_initSelect(); $this->getSelect()->where("main_table.role_type='G'"); }
/** * Attaches flat data to collection * @return AW_Sarp_Model_Mysql4_Subscription_Collection */ protected function _initselect() { parent::_initSelect(); $this->getSelect()->joinLeft(array('f' => Mage::getResourceModel('sarp/subscription_flat')->getMainTable()), 'f.subscription_id=id'); return $this; }
protected function _initSelect() { parent::_initSelect(); $this->_joinTables(); return $this; }
/** * Init collection select * * @return unknown */ public function _initSelect() { parent::_initSelect(); $this->getSelect()->joinLeft(array('primary_coupon' => $this->getTable('salesrule/coupon')), 'main_table.rule_id = primary_coupon.rule_id AND primary_coupon.is_primary = 1', array('code')); return $this; }
/** * Initialize collection select * * @return Mage_XmlConnect_Model_Mysql4_Queue_Collection */ protected function _initSelect() { parent::_initSelect(); $this->_joinTemplateName()->_joinApplicationName(); return $this; }
protected function _initSelect() { $res = parent::_initSelect(); $this->getSelect()->order('sort_order', 'ASC'); return $res; }
/** * Instantiate select joined to balance * * @return Enterprise_CustomerBalance_Model_Mysql4_Balance_History_Collection */ protected function _initSelect() { parent::_initSelect(); $this->getSelect()->joinInner(array('b' => $this->getTable('enterprise_customerbalance/balance')), 'main_table.balance_id = b.balance_id', array('customer_id' => 'b.customer_id', 'website_id' => 'b.website_id', 'base_currency_code' => 'b.base_currency_code')); return $this; }
protected function _initSelect() { parent::_initSelect(); $this->_joinAttributeSet(); return $this; }
protected function _initSelect() { parent::_initSelect(); $this->getSelect()->where("user_id > 0"); }
/** * Join reports info table */ protected function _initSelect() { parent::_initSelect(); $this->getSelect()->join(array('report' => $this->getTable('paypal/settlement_report')), 'report.report_id = main_table.report_id', array('report.account_id', 'report.report_date')); return $this; }
/** * Add status column based on dates * * @return Enterprise_CatalogEvent_Model_Mysql4_Event_Collection */ protected function _initSelect() { parent::_initSelect(); $this->getSelect()->columns(array('status' => $this->_getStatusColumnExpr())); return $this; }