コード例 #1
0
ファイル: Index.php プロジェクト: jauderho/magento-mirror
 /**
  * Add bundle price range index to Product collection
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @return Mage_Bundle_Model_Price_Index
  */
 public function addPriceIndexToCollection($collection)
 {
     $productObjects = array();
     $productIds = array();
     foreach ($collection->getItems() as $product) {
         /* @var $product Mage_Catalog_Model_Product */
         if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
             $productIds[] = $product->getEntityId();
             $productObjects[$product->getEntityId()] = $product;
         }
     }
     $websiteId = Mage::app()->getStore($collection->getStoreId())->getWebsiteId();
     $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
     $addOptionsToResult = false;
     $prices = $this->_getResource()->loadPriceIndex($productIds, $websiteId, $groupId);
     foreach ($productIds as $productId) {
         if (isset($prices[$productId])) {
             $productObjects[$productId]->setData('_price_index', true)->setData('_price_index_min_price', $prices[$productId]['min_price'])->setData('_price_index_max_price', $prices[$productId]['max_price']);
         } else {
             $addOptionsToResult = true;
         }
     }
     if ($addOptionsToResult) {
         $collection->addOptionsToResult();
     }
     return $this;
 }
コード例 #2
0
ファイル: Price.php プロジェクト: xiaoguizhidao/ortodon
 /**
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param Morphes_Filters_Model_Filter_Price $model
  * @param array $value
  * @return Morphes_Filters_Resource_Filter_Price
  */
 public function applyToCollection($collection, $model, $value)
 {
     $collection->addPriceData($model->getCustomerGroupId(), $model->getWebsiteId());
     $select = $collection->getSelect();
     $response = $this->_dispatchPreparePriceEvent($model, $select);
     $table = $this->_getIndexTableAlias();
     $additional = join('', $response->getAdditionalCalculations());
     $fix = $this->_getConfigurablePriceFix();
     $rate = $model->getCurrencyRate();
     $precision = 2;
     //$filter->getDecimalDigits();
     if ($this->isUpperBoundInclusive()) {
         $priceExpr = new Zend_Db_Expr("ROUND(({$table}.min_price {$additional} {$fix}) * {$rate}, {$precision})");
     } else {
         $priceExpr = new Zend_Db_Expr("({$table}.min_price {$additional} {$fix}) * {$rate}");
     }
     $condition = '';
     foreach ($model->getMSelectedValues() as $selection) {
         if (strpos($selection, ',') !== false) {
             list($index, $range) = explode(',', $selection);
             $range = $this->getPriceRange($index, $range);
             if ($condition != '') {
                 $condition .= ' OR ';
             }
             $condition .= '((' . $priceExpr . ' >= ' . $range['from'] . ') ' . 'AND (' . $priceExpr . ($this->isUpperBoundInclusive() ? ' <= ' : ' < ') . $range['to'] . '))';
         }
     }
     if ($condition) {
         $select->distinct()->where("NOT ({$condition})");
     }
     return $this;
 }
コード例 #3
0
ファイル: Layer.php プロジェクト: arslbbt/mangentovies
 /**
  * Enter description here...
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @return Mage_Catalog_Model_Layer
  */
 public function prepareProductCollection($collection)
 {
     $collection->addAttributeToSelect('name')->addAttributeToSelect('url_key')->addAttributeToSelect('price')->addAttributeToSelect('special_price')->addAttributeToSelect('special_from_date')->addAttributeToSelect('special_to_date')->joinMinimalPrice()->addAttributeToSelect('description')->addAttributeToSelect('short_description')->addAttributeToSelect('image')->addAttributeToSelect('thumbnail')->addAttributeToSelect('small_image')->addAttributeToSelect('tax_class_id')->addStoreFilter();
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
     return $this;
 }
コード例 #4
0
ファイル: Layer.php プロジェクト: xiaoguizhidao/mydigibits
 /**
  * Prepare product collection
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @return Mage_Catalog_Model_Layer
  */
 public function prepareProductCollection($collection)
 {
     $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText())->setStore(Mage::app()->getStore())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addStoreFilter()->addUrlRewrite();
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
     return $this;
 }
 /**
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param $categoryId
  */
 protected function _prepareProductCollection($collection, $categoryId)
 {
     $res = $collection->getResource();
     $db = $res->getReadConnection();
     $storeId = Mage::app()->getStore()->getId();
     $subSelect = $db->select()->from(array('subcat_index' => $res->getTable('catalog/category_product_index')), new Zend_Db_Expr("`subcat_index`.`product_id`"))->joinInner(array('subcat' => $res->getTable('catalog/category')), "`subcat`.`entity_id` = `subcat_index`.`category_id`", null)->where("`subcat_index`.`store_id`={$storeId} AND `subcat_index`.`visibility` IN(2, 4) AND `subcat`.`parent_id` = ?", $categoryId);
     $collection->getSelect()->where("`e`.`entity_id` IN ({$subSelect})");
 }
コード例 #6
0
 function doCollection()
 {
     $collection = new Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection();
     $collection->setStoreId(Mage::app()->getStore()->getId());
     $collection->addAttributeToSelect('*');
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
     //        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
     return $collection;
 }
コード例 #7
0
 /**
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param Mana_Filters_Model_Filter_Attribute $model
  * @param array $value
  * @return Mana_Filters_Resource_Filter_Attribute
  */
 public function applyToCollection($collection, $model, $value)
 {
     $attribute = $model->getAttributeModel();
     $connection = $this->_getReadAdapter();
     $tableAlias = $attribute->getAttributeCode() . '_idx';
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()), "{$tableAlias}.value in (" . implode(',', array_filter($value)) . ")");
     $conditions = join(' AND ', $conditions);
     $collection->getSelect()->distinct()->join(array($tableAlias => $this->getMainTable()), $conditions, array());
     return $this;
 }
コード例 #8
0
ファイル: Price.php プロジェクト: HelioFreitas/magento-pt_br
 public function addMinimalPrices(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection)
 {
     $minimalPrices = $this->_getResource()->getMinimalPrices($collection->getLoadedIds());
     foreach ($minimalPrices as $row) {
         $item = $collection->getItemById($row['entity_id']);
         if ($item) {
             $item->setData('minimal_price', $row['value']);
             $item->setData('minimal_tax_class_id', $row['tax_class_id']);
         }
     }
 }
コード例 #9
0
 /**
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param Mana_Filters_Resource_Filter_Attribute $model
  * @param array $value
  * @return Mana_Filters_Resource_Filter_Attribute
  */
 public function applyToCollection($collection, $model, $value)
 {
     $attribute = $model->getAttributeModel();
     $connection = $this->_getReadAdapter();
     foreach ($value as $i => $singleValue) {
         $tableAlias = $attribute->getAttributeCode() . '_idx' . $i;
         $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()), "{$tableAlias}.value = {$singleValue}");
         $conditions = join(' AND ', $conditions);
         $collection->getSelect()->distinct()->join(array($tableAlias => $this->getMainTable()), $conditions, array());
     }
     return $this;
 }
コード例 #10
0
 /**
  * Initialize product collection
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection Product collection.
  *
  * @return Mage_Catalog_Model_Layer
  */
 public function prepareProductCollection($collection)
 {
     $query = $collection->getSearchEngineQuery();
     $allowedVisibilities = Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds();
     $query->addFilter('terms', array('visibility' => $allowedVisibilities));
     $allowedStatuses = Mage::getSingleton('catalog/product_status')->getVisibleStatusIds();
     $query->addFilter('terms', array('status' => $allowedStatuses));
     if (Mage::helper('cataloginventory')->isShowOutOfStock() == false) {
         $query->addFilter('terms', array('in_stock' => 1));
     }
     $query->setQueryType('category_products_layer');
     return parent::prepareProductCollection($collection);
 }
コード例 #11
0
ファイル: Collection.php プロジェクト: victorkho/telor
 public function isEnabledFlat()
 {
     if (!Mage::helper('urapidflow')->hasMageFeature('flat_catalog')) {
         return false;
     }
     return parent::isEnabledFlat();
 }
コード例 #12
0
 public function getFilterCounts($code, $cache = true)
 {
     $currentFilter = $this->_filters[$code];
     /* @var $currentFilterModel Mana_Filters_Interface_Filter */
     $currentFilterModel = $currentFilter['model'];
     if (!$cache || !isset($currentFilter['processedCounts'])) {
         if (!empty($currentFilter['isCounted'])) {
             $currentFilter['processedCounts'] = $currentFilterModel->processCounts($currentFilter['counts']);
         } else {
             $mainSelect = clone $this->_productCollection->getSelect();
             $collection = $this->createProductCollection();
             //$sql = $collection->getSelect()->__toString();
             foreach ($this->_filters as $filter) {
                 /* @var $filterModel Mana_Filters_Interface_Filter */
                 $filterModel = $filter['model'];
                 if ($filter['isApplied'] && $currentFilterModel->isFilterAppliedWhenCounting($filterModel)) {
                     $filterModel->applyToCollection($collection);
                 }
             }
             $counts = $currentFilterModel->countOnCollection($collection);
             $currentFilter['processedCounts'] = $currentFilterModel->processCounts($counts);
             $this->_copyParts($this->_productCollection->getSelect(), $mainSelect);
         }
         if ($cache) {
             $this->_filters[$code] = $currentFilter;
         }
     }
     return $currentFilter['processedCounts'];
 }
コード例 #13
0
 /**
  * Get SQL for get record count
  *
  * @return Varien_Db_Select
  */
 public function getSelectCountSql()
 {
     $countSelect = parent::getSelectCountSql();
     //@nelkaake -a 15/12/10: Reset the group selection. ( for categories grouping)
     $countSelect->reset(Zend_Db_Select::GROUP);
     return $countSelect;
 }
コード例 #14
0
 protected function _getAttributeFieldName($attributeCode)
 {
     if ($attributeCode == 'days_in_wishlist') {
         return $this->_joinFields[$attributeCode]['field'];
     }
     return parent::_getAttributeFieldName($attributeCode);
 }
コード例 #15
0
ファイル: Decimal.php プロジェクト: smitmanglam/staging
 /**
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param Mana_Filters_Model_Filter_Attribute $model
  * @return Mana_Filters_Resource_Filter_Decimal
  */
 public function countOnCollection($collection, $model)
 {
     $select = $collection->getSelect();
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $attributeId = $model->getAttributeModel()->getId();
     $storeId = $collection->getStoreId();
     $select->join(array('decimal_index' => $this->getMainTable()), 'e.entity_id = decimal_index.entity_id' . ' AND ' . $this->_getReadAdapter()->quoteInto('decimal_index.attribute_id = ?', $attributeId) . ' AND ' . $this->_getReadAdapter()->quoteInto('decimal_index.store_id = ?', $storeId), array());
     $adapter = $this->_getReadAdapter();
     $countExpr = new Zend_Db_Expr("COUNT(*)");
     $rangeExpr = new Zend_Db_Expr("FLOOR(decimal_index.value / {$model->getRange()}) + 1");
     $select->columns(array('range' => $rangeExpr, 'count' => $countExpr));
     $select->group('range');
     return $adapter->fetchPairs($select);
 }
コード例 #16
0
ファイル: Sphinx.php プロジェクト: lnroma/sphinxMagento
 /**
  * add sort to result collection
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
  */
 protected function _addSortToCollection(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection)
 {
     $orderBy = Mage::app()->getRequest()->getParam('order', null);
     $orderDir = Mage::app()->getRequest()->getParam('dir', null);
     if (is_null($orderBy)) {
         return $collection;
     }
     if (is_null($orderDir)) {
         $orderDir = $collection::SORT_ORDER_DESC;
     } elseif ($orderDir == 'desc') {
         $orderDir = $collection::SORT_ORDER_DESC;
     } elseif ($orderDir == 'asc') {
         $orderDir = $collection::SORT_ORDER_ASC;
     }
     $collection->setOrder($orderBy, $orderDir);
     return $collection;
 }
コード例 #17
0
ファイル: Item.php プロジェクト: sagmahajan/aswan_release
 /**
  * @param Mana_Filters_Model_Filter_Attribute $filter
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @return Varien_Db_Select
  */
 public function countItems($filter, $collection)
 {
     $select = $collection->getSelect();
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::GROUP);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $db = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $selectedOptionIds = $filter->getMSelectedValues();
     $isSelectedExpr = count($selectedOptionIds) ? "`eav`.`value` IN (" . implode(', ', $selectedOptionIds) . ")" : "NULL";
     $fields = array('sort_order' => new Zend_Db_Expr("`o`.`sort_order`"), 'value' => new Zend_Db_Expr("`eav`.`value`"), 'label' => new Zend_Db_Expr("COALESCE(`vs`.`value`, `vg`.`value`)"), 'm_selected' => new Zend_Db_Expr($isSelectedExpr), 'm_show_selected' => new Zend_Db_Expr($filter->getFilterOptions()->getIsReverse() ? "NOT ({$isSelectedExpr})" : $isSelectedExpr));
     $select->joinInner(array('eav' => $this->getTable('catalog/product_index_eav')), "`eav`.`entity_id` = `e`.`entity_id` AND\r\n                {$db->quoteInto("`eav`.`attribute_id` = ?", $attribute->getAttributeId())} AND\r\n                {$db->quoteInto("`eav`.`store_id` = ?", $filter->getStoreId())}", array('count' => "COUNT(DISTINCT `eav`.`entity_id`)"))->joinInner(array('o' => $this->getTable('eav/attribute_option')), "`o`.`option_id` = `eav`.`value`", null)->joinInner(array('vg' => $this->getTable('eav/attribute_option_value')), $db->quoteInto("`vg`.`option_id` = `eav`.`value` AND `vg`.`store_id` = ?", 0), null)->joinLeft(array('vs' => $this->getTable('eav/attribute_option_value')), $db->quoteInto("`vs`.`option_id` = `eav`.`value` AND `vs`.`store_id` = ?", $filter->getStoreId()), null)->columns($fields)->group($fields);
     //$sql = $select->__toString();
     return $select;
 }
コード例 #18
0
 public function addAttributeToSort($attribute, $dir = 'asc')
 {
     if (in_array($attribute, array('review_cnt', 'last_created', 'avg_rating', 'avg_rating_approved'))) {
         $this->getSelect()->order($attribute . ' ' . $dir);
         return $this;
     }
     return parent::addAttributeToSort($attribute, $dir);
 }
コード例 #19
0
ファイル: Collection.php プロジェクト: jpbender/mage_virtual
 /**
  * Set Order field
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
  */
 public function setOrder($attribute, $dir = 'desc')
 {
     if ($attribute == 'relevance') {
         $this->getSelect()->order("relevance {$dir}");
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
コード例 #20
0
ファイル: Product.php プロジェクト: EagleSH/besttoy
 /**
  * Covers bug in Magento function
  * @return Varien_Db_Select
  */
 public function getSelectCountSql()
 {
     $catalogProductFlatHelper = Mage::helper('catalog/product_flat');
     if ($catalogProductFlatHelper && $catalogProductFlatHelper->isEnabled()) {
         return parent::getSelectCountSql();
     }
     $this->_renderFilters();
     $countSelect = clone $this->getSelect();
     return $countSelect->reset()->from($this->getSelect(), array())->columns('COUNT(*)');
 }
コード例 #21
0
ファイル: Collection.php プロジェクト: jpbender/mage_virtual
 /**
  * Add filtering
  *
  * @return Mage_Reports_Model_Mysql4_Product_Downloads_Collection
  */
 public function addFieldToFilter($field, $condition = null)
 {
     if ($field == 'link_title') {
         $conditionSql = $this->_getConditionSql('l.title', $condition);
         $this->getSelect()->where($conditionSql);
     } else {
         parent::addFieldToFilter($field, $condition);
     }
     return $this;
 }
コード例 #22
0
ファイル: Decimal.php プロジェクト: xiaoguizhidao/ortodon
 /**
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param Morphes_Filters_Model_Filter_Decimal $model
  * @param array $value
  * @return Morphes_Filters_Resource_Filter_Decimal
  */
 public function applyToCollection($collection, $model, $value)
 {
     $attribute = $model->getAttributeModel();
     $connection = $this->_getReadAdapter();
     $tableAlias = $attribute->getAttributeCode() . '_idx';
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()));
     $condition = '';
     foreach ($value as $selection) {
         if (strpos($selection, ',') !== false) {
             list($index, $range) = explode(',', $selection);
             $range = $this->getRange($index, $range);
             if ($condition != '') {
                 $condition .= ' OR ';
             }
             $condition .= '((' . "{$tableAlias}.value" . ' >= ' . $range['from'] . ') ' . 'AND (' . "{$tableAlias}.value" . ($this->isUpperBoundInclusive() ? ' <= ' : ' < ') . $range['to'] . '))';
         }
     }
     if ($condition) {
         $collection->getSelect()->join(array($tableAlias => $this->getMainTable()), join(' AND ', $conditions), array())->distinct()->where("NOT ({$condition})");
     }
     return $this;
 }
コード例 #23
0
 public function getAllIds($limit = null, $offset = null)
 {
     if (!$this->listingProductMode) {
         return parent::getAllIds($limit, $offset);
     }
     // hack for selecting listing product ids instead entity ids
     $idsSelect = clone $this->getSelect();
     $idsSelect->reset(Zend_Db_Select::ORDER);
     $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
     $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
     $idsSelect->reset(Zend_Db_Select::COLUMNS);
     $idsSelect->columns('lp.' . $this->getIdFieldName());
     $idsSelect->limit($limit, $offset);
     $idsSelect->resetJoinLeft();
     return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
 }
コード例 #24
0
 public function getAllIds($limit = null, $offset = null)
 {
     if (!$this->listingProductMode) {
         return parent::getAllIds($limit, $offset);
     }
     // hack for selecting listing product ids instead entity ids
     $idsSelect = clone $this->getSelect();
     $idsSelect->reset(Zend_Db_Select::ORDER);
     $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
     $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
     $idsSelect->columns('lp.' . $this->getIdFieldName());
     $idsSelect->limit($limit, $offset);
     $data = $this->getConnection()->fetchAll($idsSelect, $this->_bindParams);
     $ids = array();
     foreach ($data as $row) {
         $ids[] = $row[$this->getIdFieldName()];
     }
     return $ids;
 }
コード例 #25
0
ファイル: Query.php プロジェクト: smitmanglam/staging
 public function getAllOptimizedAttributeFilterCounts()
 {
     if (!$this->_allOptimizedAttributeFilterCounts) {
         $attributeIds = array();
         $firstModel = null;
         /* @var $firstModel Mana_Filters_Model_Filter_Attribute */
         foreach ($this->_filters as $filter) {
             $model = $filter['model'];
             if ($this->isOptimizedAttributeFilter($model)) {
                 if (!$firstModel) {
                     $firstModel = $model;
                 }
                 /* @var $model Mana_Filters_Model_Filter_Attribute */
                 $id = $model->getAttributeModel()->getId();
                 $attributeIds[$id] = $id;
             }
         }
         $mainSelect = clone $this->_productCollection->getSelect();
         $collection = $this->createProductCollection();
         foreach ($this->_filters as $filter) {
             if ($filter['isApplied']) {
                 /* @var $filterModel Mana_Filters_Interface_Filter */
                 $filterModel = $filter['model'];
                 $applyFilter = true;
                 foreach ($this->_filters as $optimizedFilter) {
                     /* @var $model Mana_Filters_Model_Filter_Attribute */
                     $model = $optimizedFilter['model'];
                     if ($this->isOptimizedAttributeFilter($model) && !$model->isFilterAppliedWhenCounting($filterModel)) {
                         $applyFilter = false;
                         break;
                     }
                 }
                 if ($applyFilter) {
                     $filterModel->applyToCollection($collection);
                 }
             }
         }
         $this->_allOptimizedAttributeFilterCounts = $firstModel ? $firstModel->optimizedCountOnCollection($collection, $attributeIds) : array();
         $this->_copyParts($this->_productCollection->getSelect(), $mainSelect);
     }
     return $this->_allOptimizedAttributeFilterCounts;
 }
コード例 #26
0
 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();
 }
コード例 #27
0
ファイル: Abstract.php プロジェクト: jpbender/mage_virtual
 /**
  * Retrieve related product collection assigned to product
  *
  * @throws Mage_Core_Exception
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
  */
 public function getLinkCollection()
 {
     if (is_null($this->_linkCollection)) {
         switch ($this->getType()) {
             case Enterprise_TargetRule_Model_Rule::RELATED_PRODUCTS:
                 $this->_linkCollection = $this->getProduct()->getRelatedProductCollection();
                 break;
             case Enterprise_TargetRule_Model_Rule::UP_SELLS:
                 $this->_linkCollection = $this->getProduct()->getUpSellProductCollection();
                 break;
             default:
                 Mage::throwException(Mage::helper('enterprise_targetrule')->__('Undefined Catalog Product List Type'));
         }
         $this->_addProductAttributesAndPrices($this->_linkCollection);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_linkCollection);
         $this->_linkCollection->addAttributeToSort('position', 'ASC')->setFlag('do_not_use_category_id', true)->setPageSize($this->getPositionLimit());
         $excludeProductIds = $this->getExcludeProductIds();
         if ($excludeProductIds) {
             $this->_linkCollection->addAttributeToFilter('entity_id', array('nin' => $excludeProductIds));
         }
     }
     return $this->_linkCollection;
 }
コード例 #28
0
 /**
  * Collect validated attributes
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection
  * @return Mage_CatalogRule_Model_Rule_Condition_Product
  */
 public function collectValidatedAttributes($productCollection)
 {
     $attribute = $this->getAttribute();
     if ($attribute == 'category_ids' || $this->isFilterCustom($attribute)) {
         return $this;
     }
     if ($this->getAttributeObject()->isScopeGlobal()) {
         $attributes = $this->getRule()->getCollectedAttributes();
         $attributes[$attribute] = true;
         $this->getRule()->setCollectedAttributes($attributes);
         $productCollection->addAttributeToSelect($attribute, 'left');
     } else {
         $this->_entityAttributeValues = $productCollection->getAllAttributeValues($attribute);
     }
     return $this;
 }
コード例 #29
0
 /**
  * Redeclare parent method for store filters applying
  *
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
  */
 protected function _beforeLoad()
 {
     parent::_beforeLoad();
     $this->_applyStoresFilterToSelect();
     return $this;
 }
コード例 #30
0
ファイル: Collection.php プロジェクト: jpbender/mage_virtual
 /**
  * Join linked products when specified link model
  *
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link_Product_Collection
  */
 protected function _beforeLoad()
 {
     if ($this->getLinkModel()) {
         $this->_joinLinks();
     }
     return parent::_beforeLoad();
 }