当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection类代码示例

本文整理汇总了PHP中Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection类的具体用法?PHP Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection怎么用?PHP Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addPriceIndexToCollection

 /**
  * 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;
 }
开发者ID:jauderho,项目名称:magento-mirror,代码行数:33,代码来源:Index.php

示例2: applyToCollection

 /**
  * @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;
 }
开发者ID:xiaoguizhidao,项目名称:ortodon,代码行数:38,代码来源:Price.php

示例3: prepareProductCollection

 /**
  * 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;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:13,代码来源:Layer.php

示例4: prepareProductCollection

 /**
  * 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;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:13,代码来源:Layer.php

示例5: _prepareProductCollection

 /**
  * @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})");
 }
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:12,代码来源:ExcludeProductsNotAssignedToSubCategories.php

示例6: doCollection

 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;
 }
开发者ID:hashir-dhattiwala,项目名称:vfmagento,代码行数:9,代码来源:Product.php

示例7: applyToCollection

 /**
  * @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;
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:16,代码来源:Attribute.php

示例8: addMinimalPrices

 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']);
         }
     }
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:11,代码来源:Price.php

示例9: applyToCollection

 /**
  * @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;
 }
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:18,代码来源:Attribute.php

示例10: prepareProductCollection

 /**
  * 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);
 }
开发者ID:ngocdb,项目名称:smile-magento-elasticsearch,代码行数:20,代码来源:Layer.php

示例11: countOnCollection

 /**
  * @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);
 }
开发者ID:smitmanglam,项目名称:staging,代码行数:22,代码来源:Decimal.php

示例12: _addSortToCollection

 /**
  * 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;
 }
开发者ID:lnroma,项目名称:sphinxMagento,代码行数:22,代码来源:Sphinx.php

示例13: countItems

 /**
  * @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;
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:22,代码来源:Item.php

示例14: isEnabledFlat

 public function isEnabledFlat()
 {
     if (!Mage::helper('urapidflow')->hasMageFeature('flat_catalog')) {
         return false;
     }
     return parent::isEnabledFlat();
 }
开发者ID:victorkho,项目名称:telor,代码行数:7,代码来源:Collection.php

示例15: getFilterCounts

 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'];
 }
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:29,代码来源:Query.php


注:本文中的Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。