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


PHP Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection::getProductCountSelect方法代码示例

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


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

示例1: addCountToCategories

 /**
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection
  * @param $categoryCollection
  * @param bool $inCurrentCategory
  * @return $this
  */
 public function addCountToCategories($productCollection, $categoryCollection, $inCurrentCategory = false)
 {
     Mana_Core_Profiler2::start(__METHOD__);
     $isAnchor = array();
     $isNotAnchor = array();
     foreach ($categoryCollection as $category) {
         if ($category->getIsAnchor()) {
             $isAnchor[] = $category->getId();
         } else {
             $isNotAnchor[] = $category->getId();
         }
     }
     $productCounts = array();
     if ($isAnchor || $isNotAnchor) {
         /* @var $select Varien_Db_Select */
         $select = $productCollection->getProductCountSelect();
         if ($inCurrentCategory) {
             $from = $select->getPart(Varien_Db_Select::FROM);
             if (isset($from['cat_index'])) {
                 $categoryId = $this->getLayer()->getCurrentCategory()->getId();
                 $from['cat_index']['joinCondition'] = preg_replace("/(.*)(`?)cat_index(`?).(`?)category_id(`?)='(\\d+)'(.*)/", "\$1\$2cat_index\$3.\$4category_id\$5='{$categoryId}'\$7", $from['cat_index']['joinCondition']);
                 $select->setPart(Varien_Db_Select::FROM, $from);
             }
         }
         Mage::dispatchEvent('catalog_product_collection_before_add_count_to_categories', array('collection' => $productCollection));
         if ($isAnchor) {
             $anchorStmt = clone $select;
             $anchorStmt->limit();
             //reset limits
             $anchorStmt->where('count_table.category_id IN (?)', $isAnchor);
             $sql = $anchorStmt->__toString();
             $productCounts += $productCollection->getConnection()->fetchPairs($anchorStmt);
             $anchorStmt = null;
         }
         if ($isNotAnchor) {
             $notAnchorStmt = clone $select;
             $notAnchorStmt->limit();
             //reset limits
             $notAnchorStmt->where('count_table.category_id IN (?)', $isNotAnchor);
             $notAnchorStmt->where('count_table.is_parent = 1');
             $productCounts += $productCollection->getConnection()->fetchPairs($notAnchorStmt);
             $notAnchorStmt = null;
         }
         $select = null;
         $productCollection->unsProductCountSelect();
     }
     foreach ($categoryCollection as $category) {
         $_count = 0;
         if (isset($productCounts[$category->getId()])) {
             $_count = $productCounts[$category->getId()];
         }
         $category->setProductCount($_count);
     }
     Mana_Core_Profiler2::stop();
     return $this;
 }
开发者ID:VizualAbstract,项目名称:multiple-select-nav,代码行数:62,代码来源:Data.php

示例2: addIndexToProductCount

 /**
  * Add index to product count select in product collection
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param int $customerGroupId
  * @return Enterprise_CatalogPermissions_Model_Mysql4_Permission_Index
  */
 public function addIndexToProductCount($collection, $customerGroupId)
 {
     $parts = $collection->getSelect()->getPart(Zend_Db_Select::FROM);
     if (isset($parts['permission_index_product'])) {
         return $this;
     }
     $collection->getProductCountSelect()->joinLeft(array('permission_index_product_count' => $this->getTable('permission_index_product')), 'permission_index_product_count.category_id = count_table.category_id AND
              permission_index_product_count.product_id = count_table.product_id AND
              permission_index_product_count.store_id = count_table.store_id AND
              permission_index_product_count.customer_group_id = ' . (int) $customerGroupId, array());
     if (!Mage::helper('enterprise_catalogpermissions')->isAllowedCategoryView()) {
         $collection->getProductCountSelect()->where('permission_index_product_count.grant_catalog_category_view = ' . Enterprise_CatalogPermissions_Model_Permission::PERMISSION_ALLOW);
     } else {
         $collection->getProductCountSelect()->where('permission_index_product_count.grant_catalog_category_view != ' . Enterprise_CatalogPermissions_Model_Permission::PERMISSION_DENY . '
                      OR permission_index_product_count.grant_catalog_category_view IS NULL');
     }
     return $this;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:25,代码来源:Index.php


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