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


PHP Mage_Catalog_Model_Category::getChildrenCategories方法代码示例

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


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

示例1: printCategoryChildrenOpt

 protected function printCategoryChildrenOpt(Mage_Catalog_Model_Category $category)
 {
     /**
      * @var $child Mage_Catalog_Model_Category
      */
     $children = $category->getChildrenCategories();
     foreach ($children as $child) {
         echo "<p>&nbsp;&nbsp;&nbsp;<b>Child cat#{$child->getId()}&nbsp;</b>::&nbsp;{$child->getName()}</p>";
     }
 }
开发者ID:skvskv-php-self-education,项目名称:MagentoTraining,代码行数:10,代码来源:ModelsController.php

示例2: _getItemsData

 /**
  * Get data array for building filter items
  *
  * @return array
  */
 protected function _getItemsData()
 {
     $key = $this->getLayer()->getStateKey() . '_' . $this->_requestVar;
     $data = $this->getLayer()->getAggregator()->getCacheData($key);
     if ($data === null) {
         // load children for root category or current selected category for this filter
         $categories = $this->_appliedCategory instanceof Mage_Catalog_Model_Category ? $this->_appliedCategory->getChildrenCategories() : $this->_rootCategory->getChildrenCategories();
         $this->getLayer()->getProductCollection()->addCountToCategories($categories);
         $data = array();
         foreach ($categories as $category) {
             /** @var $category Mage_Catalog_Model_Categeory */
             if ($category->getIsActive() && $category->getProductCount()) {
                 $data[] = array('label' => Mage::helper('core')->escapeHtml($category->getName()), 'value' => $category->getId(), 'count' => $category->getProductCount());
             }
         }
         $tags = $this->getLayer()->getStateTags();
         $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
     }
     return $data;
 }
开发者ID:bitbull-team,项目名称:magento-module-category-layered,代码行数:25,代码来源:CategoryLayered.php

示例3: getChildCategories

 /**
  * Recursively returns a value / label array of all active categories
  * @param Mage_Catalog_Model_Category $category
  * @param String $parentname
  * @return array
  */
 private function getChildCategories($category, $parentname = '')
 {
     //category not active - skip it
     if (!$category->getIsActive()) {
         return '';
     }
     //array containing all the categories to return
     $ret = array();
     /* Add the current category to return array
      * Root categories shouldn't be selected
      */
     if ($category->getLevel() > 1) {
         $ret[$category->getID()] = $category->getName() . $parentname;
     }
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildrenCategories();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     /**
      * Use recursion to include all children categories too
      */
     foreach ($activeChildren as $child) {
         $childarray = $this->getChildCategories($child, " / " . $category->getName() . $parentname);
         foreach ($childarray as $k => $v) {
             $ret[$k] = $v;
         }
     }
     return $ret;
 }
开发者ID:jtoshmat,项目名称:mystore,代码行数:49,代码来源:Categories.php

示例4: getChildCategories

 /**
  * Recursively returns a value / label array of all active categories
  *
  * @param Mage_Catalog_Model_Category $category
  * @param String $parentname
  * @return array
  */
 private function getChildCategories($category, $parentname = '')
 {
     //category not active - skip it
     if (!$category->getIsActive()) {
         return '';
     }
     //array containing all the categories to return
     $ret = array();
     /* Add the current category to return array
      * Root categories shouldn't be selected
      */
     if ($category->getLevel() > 1) {
         $ret[$category->getID()] = ltrim($parentname . " / " . $category->getName(), " / ");
     }
     // get all children
     $children = $category->getChildrenCategories();
     $childrenCount = $children->count();
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     /**
      * Use recursion to include all children categories too
      */
     foreach ($activeChildren as $child) {
         $childarray = $this->getChildCategories($child, $parentname . " / " . $category->getName());
         foreach ($childarray as $k => $v) {
             $ret[$k] = ltrim($v, " / ");
         }
     }
     return $ret;
 }
开发者ID:ironizm,项目名称:background_image,代码行数:45,代码来源:Categories.php

示例5: testGetChildrenCategoriesEmpty

 public function testGetChildrenCategoriesEmpty()
 {
     $this->_model->load(5);
     $children = $this->_model->getChildrenCategories();
     $this->assertEquals(0, count($children));
 }
开发者ID:nemphys,项目名称:magento2,代码行数:6,代码来源:CategoryTreeTest.php

示例6: getSubcategories

 /**
  * Returns list of subcategories recursively.
  *
  * @param Mage_Catalog_Model_Category $category
  * @return mixed
  */
 protected function getSubcategories(Mage_Catalog_Model_Category $category)
 {
     if (!isset($this->subcategories[$category->getId()])) {
         $list = array();
         $categories = $category->getChildrenCategories();
         $this->getAllChildCategories($categories, $list);
         $this->subcategories[$category->getId()] = $list;
     }
     return $this->subcategories[$category->getId()];
 }
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:16,代码来源:Category.php

示例7: getAllChildrenCategories

 /**
  * 
  *
  * @param array $arr_cat
  * @param Mage_Catalog_Model_Category $category
  * @return array
  */
 public static function getAllChildrenCategories(&$arr_cat, $category, $fl_include_cur_cat = true)
 {
     if (empty($arr_cat)) {
         $arr_cat = array();
     }
     if (!empty($category)) {
         if ($fl_include_cur_cat == true) {
             $arr_cat[] = $category->getId();
         }
         $children_cat = $category->getChildrenCategories();
         if (!empty($children_cat)) {
             foreach ($children_cat as $cat) {
                 self::getAllChildrenCategories($arr_cat, $cat, $fl_include_cur_cat);
             }
         }
     }
     return $arr_cat;
 }
开发者ID:kozinthetdbp,项目名称:shopmyar,代码行数:25,代码来源:ApiCategories.php


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