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


PHP Mage_Catalog_Model_Category::getProductCount方法代码示例

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


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

示例1: testGetProductCount

 public function testGetProductCount()
 {
     $this->_model->load(6);
     $this->assertEquals(0, $this->_model->getProductCount());
     $this->_model->setData(array());
     $this->_model->load(3);
     $this->assertEquals(1, $this->_model->getProductCount());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:8,代码来源:CategoryTest.php

示例2: exportData

 protected function exportData(Mage_Catalog_Model_Category $category, $file, $depth = 0)
 {
     $data = array('id' => $category->getId(), 'parent_id' => $category->getParentId(), 'attribute_set_id' => $category->getAttributeSetId(), 'urlPath' => $category->getUrlPath(), 'urlKey' => $category->getUrlKey(), 'path' => $category->getPath(), 'position' => $category->getPosition(), 'page_layout' => $category->getPageLayout(), 'description' => $category->getDescription(), 'display_mode' => $category->getDisplayMode(), 'is_active' => $category->getIsActive(), 'is_anchor' => $category->getIsAnchor(), 'include_in_menu' => $category->getIncludeInMenu(), 'custom_design' => $category->getCustomDesign(), 'level' => $category->getLevel(), 'name' => $category->getName(), 'metaTitle' => $category->getMetaTitle(), 'metaKeywords' => $category->getMetaKeywords(), 'metaDescription' => $category->getMetaDescription());
     echo str_repeat('  ', $depth);
     echo '* ' . $category->getName() . sprintf(' (%s products)', $category->getProductCount()) . PHP_EOL;
     fputcsv($file, $data);
     if ($category->hasChildren()) {
         $children = Mage::getModel('catalog/category')->getCategories($category->getId());
         foreach ($children as $child) {
             $child = Mage::getModel('catalog/category')->load($child->getId());
             $this->exportData($child, $file, $depth + 1);
         }
     }
 }
开发者ID:sonaht,项目名称:magento-category-migration,代码行数:14,代码来源:exportCategories.php

示例3: _getProductCount

 /**
  * @param Mage_Catalog_Model_Category $category
  * @return mixed
  */
 protected function _getProductCount($category)
 {
     /** @var Amasty_Shopby_Helper_Data $helper */
     $helper = Mage::helper('amshopby');
     if ($helper->useSolr()) {
         // not implemented yet
         return null;
     } else {
         return $category->getProductCount();
     }
 }
开发者ID:xiaoguizhidao,项目名称:tyler-live,代码行数:15,代码来源:Category.php

示例4: getObject

 public function getObject(Mage_Catalog_Model_Category $category)
 {
     /** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
     $productCollection = $category->getProductCollection();
     $category->setProductCount($productCollection->addMinimalPrice()->count());
     $transport = new Varien_Object();
     Mage::dispatchEvent('algolia_category_index_before', array('category' => $category, 'custom_data' => $transport));
     $customData = $transport->getData();
     $storeId = $category->getStoreId();
     $category->getUrlInstance()->setStore($storeId);
     $path = '';
     foreach ($category->getPathIds() as $categoryId) {
         if ($path != '') {
             $path .= ' / ';
         }
         $path .= $this->getCategoryName($categoryId, $storeId);
     }
     $image_url = NULL;
     try {
         $image_url = $category->getImageUrl();
     } catch (Exception $e) {
         /* no image, no default: not fatal */
     }
     $data = array('objectID' => $category->getId(), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => $category->getUrl(), '_tags' => array('category'), 'popularity' => 1, 'product_count' => $category->getProductCount());
     if (!empty($image_url)) {
         $data['image_url'] = $image_url;
     }
     foreach ($this->config->getCategoryAdditionalAttributes($storeId) as $attribute) {
         $value = $category->getData($attribute['attribute']);
         $attribute_ressource = $category->getResource()->getAttribute($attribute['attribute']);
         if ($attribute_ressource) {
             $value = $attribute_ressource->getFrontend()->getValue($category);
         }
         if (isset($data[$attribute['attribute']])) {
             $value = $data[$attribute['attribute']];
         }
         if ($value) {
             $data[$attribute['attribute']] = $value;
         }
     }
     $data = array_merge($data, $customData);
     foreach ($data as &$data0) {
         $data0 = $this->try_cast($data0);
     }
     return $data;
 }
开发者ID:halk,项目名称:algoliasearch-magento,代码行数:46,代码来源:Categoryhelper.php

示例5: _getProductCount

 /**
  * Return the number of products assigned to the category
  *
  * @param Mage_Catalog_Model_Category|Varien_Data_Tree_Node $category
  * @return int
  */
 protected function _getProductCount($category)
 {
     if (null === ($count = $category->getData('product_count'))) {
         $count = 0;
         if ($category instanceof Mage_Catalog_Model_Category) {
             $count = $category->getProductCount();
         } elseif ($category instanceof Varien_Data_Tree_Node) {
             $count = $this->_getProductCountFromTreeNode($category);
         }
     }
     return $count;
 }
开发者ID:gruenspar,项目名称:VertNav,代码行数:18,代码来源:Navigation.php

示例6: _prepareItemData

 /**
  * Prepare category row
  * @param Mage_Catalog_Model_Category $category
  * @param unknown_type $id
  * @param unknown_type $isSelected
  * @param unknown_type $level
  * @param unknown_type $isFolded
  * @return array
  */
 protected function _prepareItemData($category, $id, $isSelected, $level = 1, $isFolded = false, $skipCount = false)
 {
     $row = null;
     /*
      * Display only active category and having products or being parents 
      */
     if ($category->getIsActive() && ($skipCount || $category->getProductCount())) {
         $row = array('label' => Mage::helper('core')->htmlEscape($category->getName()), 'value' => Mage::helper('amshopby/url')->getCategoryUrl($category), 'count' => $skipCount ? 0 : $category->getProductCount(), 'level' => $level, 'id' => $id, 'is_folded' => $isFolded, 'is_selected' => $isSelected);
     }
     return $row;
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:20,代码来源:Category.php

示例7: _getProductCount

 /**
  * @param Mage_Catalog_Model_Category $category
  * @return mixed
  */
 protected function _getProductCount($category)
 {
     if ($this->_getDataHelper()->useSolr()) {
         /** @var Enterprise_Search_Model_Resource_Collection $productCollection */
         //            $productCollection = $this->getLayer()->getProductCollection();
         //            $categoriesCount = $productCollection->getFacetedData('category_ids');
         //            return isset($categoriesCount[$category->getId()]) ? $categoriesCount[$category->getId()] : null;
         // Disabled, course still buggy
         return null;
     } else {
         return $category->getProductCount();
     }
 }
开发者ID:rcclaudrey,项目名称:dev,代码行数:17,代码来源:Category.php


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