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


PHP Mage_Catalog_Model_Category::getPathIds方法代码示例

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


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

示例1: getResetValue

 /**
  * Get filter value for reset current filter state
  *
  * @return mixed
  */
 public function getResetValue()
 {
     if ($this->_appliedCategory) {
         /**
          * Revert path ids
          */
         $pathIds = array_reverse($this->_appliedCategory->getPathIds());
         $curCategoryId = $this->getLayer()->getCurrentCategory()->getId();
         if (isset($pathIds[1]) && $pathIds[1] != $curCategoryId) {
             return $pathIds[1];
         }
     }
     return null;
 }
开发者ID:relue,项目名称:magento2,代码行数:19,代码来源:Category.php

示例2: getFirstLevelCategory

 /**
  * @param Mage_Catalog_Model_Category $category
  * @return Mage_Catalog_Model_Category
  */
 public function getFirstLevelCategory($category)
 {
     if (!isset($this->_firstLevelCategories[$category->getId()])) {
         $rootId = Mage::app()->getStore()->getRootCategoryId();
         $id = $rootId;
         $rootFound = false;
         foreach ($category->getPathIds() as $pathId) {
             if ($rootFound) {
                 $id = $pathId;
                 break;
             } else {
                 if ($pathId == $rootId) {
                     $rootFound = true;
                 }
             }
         }
         if ($id == $category->getId()) {
             $this->_firstLevelCategories[$category->getId()] = $category;
         } elseif ($id == $rootId) {
             $this->_firstLevelCategories[$category->getId()] = $this->getRootCategory();
         } else {
             $this->_firstLevelCategories[$category->getId()] = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($id);
         }
     }
     return $this->_firstLevelCategories[$category->getId()];
 }
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:30,代码来源:Data.php

示例3: testGetPathIds

 public function testGetPathIds()
 {
     $this->assertEquals(array(''), $this->_model->getPathIds());
     $this->_model->setPathIds(array(1));
     $this->assertEquals(array(1), $this->_model->getPathIds());
     $this->_model->unsetData();
     $this->_model->setPath('1/2/3');
     $this->assertEquals(array(1, 2, 3), $this->_model->getPathIds());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:9,代码来源:CategoryTreeTest.php

示例4: getLayoutHandles

 private function getLayoutHandles()
 {
     $handlePrefix = 'CATEGORY';
     //if we are taking a look at a category page we don't add handles
     if (in_array('catalog_product_view', $this->layout->getUpdate()->getHandles())) {
         $handlePrefix = 'PRODUCT_CATEGORY';
     }
     //We add the category paths here, ex: CATEGORY_123 and CATEGORY_12_child
     $path = array_reverse(array_slice($this->category->getPathIds(), 1, -1));
     foreach ($path as $id) {
         $elem = array_pop($path);
         $count = count($path);
         $handle = $handlePrefix . '_' . $elem;
         for ($i = 0; $i <= $count; $i++) {
             $handle .= '_child';
         }
         $this->addHandle($handle);
         $this->addHandle(substr($handle, 0, strrpos($handle, 'child')) . $this->category->getUrlKey());
     }
 }
开发者ID:bennoislost,项目名称:extra-layout-handles,代码行数:20,代码来源:Category.php

示例5: getObject

 public function getObject(Mage_Catalog_Model_Category $category)
 {
     /** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
     $productCollection = $category->getProductCollection();
     $productCollection = $productCollection->addMinimalPrice();
     $category->setProductCount($productCollection->getSize());
     $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' => Mage::getBaseUrl() . $category->getRequestPath(), '_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:IvanRybakov,项目名称:algoliasearch-magento,代码行数:47,代码来源:Categoryhelper.php

示例6: changeParent

 /**
  * Move category to another parent node
  *
  * @param Mage_Catalog_Model_Category $category
  * @param Mage_Catalog_Model_Category $newParent
  * @param null|int $afterCategoryId
  * @return Mage_Catalog_Model_Resource_Category
  */
 public function changeParent(Mage_Catalog_Model_Category $category, Mage_Catalog_Model_Category $newParent, $afterCategoryId = null)
 {
     $childrenCount = $this->getChildrenCount($category->getId()) + 1;
     $table = $this->getEntityTable();
     $adapter = $this->_getWriteAdapter();
     $levelFiled = $adapter->quoteIdentifier('level');
     $pathField = $adapter->quoteIdentifier('path');
     /**
      * Decrease children count for all old category parent categories
      */
     $adapter->update($table, array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)), array('entity_id IN(?)' => $category->getParentIds()));
     /**
      * Increase children count for new category parents
      */
     $adapter->update($table, array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)), array('entity_id IN(?)' => $newParent->getPathIds()));
     $position = $this->_processPositions($category, $newParent, $afterCategoryId);
     $newPath = sprintf('%s/%s', $newParent->getPath(), $category->getId());
     $newLevel = $newParent->getLevel() + 1;
     $levelDisposition = $newLevel - $category->getLevel();
     /**
      * Update children nodes path
      */
     $adapter->update($table, array('path' => new Zend_Db_Expr('REPLACE(' . $pathField . ',' . $adapter->quote($category->getPath() . '/') . ', ' . $adapter->quote($newPath . '/') . ')'), 'level' => new Zend_Db_Expr($levelFiled . ' + ' . $levelDisposition)), array($pathField . ' LIKE ?' => $category->getPath() . '/%'));
     /**
      * Update moved category data
      */
     $data = array('path' => $newPath, 'level' => $newLevel, 'position' => $position, 'parent_id' => $newParent->getId());
     $adapter->update($table, $data, array('entity_id = ?' => $category->getId()));
     // Update category object to new data
     $category->addData($data);
     return $this;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:40,代码来源:Category.php

示例7: getParentDesignCategory

 /**
  * Return parent category of current category with own custom design settings
  *
  * @param Mage_Catalog_Model_Category $category
  * @return Mage_Catalog_Model_Category
  */
 public function getParentDesignCategory($category)
 {
     $adapter = $this->_getReadAdapter();
     $levelField = $adapter->quoteIdentifier('level');
     $pathIds = array_reverse($category->getPathIds());
     $select = $adapter->select()->from(array('main_table' => $this->getMainStoreTable($category->getStoreId())), '*')->where('entity_id IN (?)', $pathIds)->where('custom_use_parent_settings = ?', 0)->where($levelField . ' != ?', 0)->order('level ' . Varien_Db_Select::SQL_DESC);
     $result = $adapter->fetchRow($select);
     return Mage::getModel('catalog/category')->setData($result);
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:15,代码来源:Flat.php

示例8: getStoreIds

 /**
  * Get store identifiers where category is presented
  *
  * @deprecated after 1.3.2.2 moved to model
  * @param   Mage_Catalog_Model_Category $category
  * @return  array
  */
 public function getStoreIds($category)
 {
     if (!$category->getId()) {
         return array();
     }
     $nodes = array();
     foreach ($category->getPathIds() as $id) {
         $nodes[] = $id;
     }
     $stores = array();
     $storeCollection = Mage::getModel('core/store')->getCollection()->loadByCategoryIds($nodes);
     foreach ($storeCollection as $store) {
         $stores[$store->getId()] = $store->getId();
     }
     $entityStoreId = $category->getStoreId();
     if (!in_array($entityStoreId, $stores)) {
         array_unshift($stores, $entityStoreId);
     }
     if (!in_array(0, $stores)) {
         array_unshift($stores, 0);
     }
     return $stores;
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:30,代码来源:Category.php

示例9: getParentCategoriesForCategory

 /**
  * Return all parent categories for the given category
  * 
  * @param Mage_Catalog_Model_Category $category
  * @return Mage_Catalog_Model_Category[]
  */
 public function getParentCategoriesForCategory(Mage_Catalog_Model_Category $category)
 {
     if (!isset($this->_parents[$category->getId()])) {
         $parent = null;
         $parents = array();
         foreach ($category->getPathIds() as $parentId) {
             if ($parent = $this->getAllParentCategories()->getItemById($parentId)) {
                 // Set flag for css class
                 if (empty($parents)) {
                     $parent->setIsBase(true);
                 }
                 $parents[] = $parent;
             }
         }
         if ($parent) {
             $parent->setIsHead(true);
         }
         $this->_parents[$category->getId()] = $parents;
     }
     // Set flag for css class and separator
     return $this->_parents[$category->getId()];
 }
开发者ID:xxorax,项目名称:VinaiKopp_ProductCategories,代码行数:28,代码来源:CategoryList.php

示例10: _getCategoryPath

 /**
  * @param Mage_Catalog_Model_Category $category
  * @return string
  */
 protected function _getCategoryPath($category)
 {
     $categoryPathIds = $category->getPathIds();
     array_shift($categoryPathIds);
     $categoryNames = array();
     foreach ($categoryPathIds as $categoryId) {
         $categoryNames[] = Mage::getResourceSingleton('catalog/category')->getAttributeRawValue($categoryId, 'name', $category->getStoreId());
     }
     return implode(' > ', $categoryNames);
 }
开发者ID:par-orillonsoft,项目名称:FireGento_FlexCms,代码行数:14,代码来源:PublishController.php

示例11: getCategoryJSON

 /**
  * Prepare category JSON
  *
  * @param Mage_Catalog_Model_Category $category
  * @return array
  */
 public function getCategoryJSON(Mage_Catalog_Model_Category $category)
 {
     $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);
     }
     $imageUrl = NULL;
     try {
         $imageUrl = $category->getImageUrl();
     } catch (Exception $e) {
         /* no image, no default: not fatal */
     }
     $data = array('objectID' => $this->getCategoryObjectId($category), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => $category->getUrl(), '_tags' => array('category'), 'popularity' => 1);
     if ($this->isIndexProductCount()) {
         $data['product_count'] = $data['popularity'] = $category->getProductCount();
     }
     if (!empty($imageUrl)) {
         $data['image_url'] = $imageUrl;
     }
     foreach ($this->getCategoryAdditionalAttributes($storeId) as $attributeCode) {
         $value = $category->hasData($this->_dataPrefix . $attributeCode) ? $category->getData($this->_dataPrefix . $attributeCode) : $category->getData($attributeCode);
         $value = Mage::getResourceSingleton('algoliasearch/fulltext')->getAttributeValue($attributeCode, $value, $storeId, Mage_Catalog_Model_Category::ENTITY);
         if ($value) {
             $data[$attributeCode] = $value;
         }
     }
     $data = array_merge($data, $customData);
     return $data;
 }
开发者ID:par-orillonsoft,项目名称:algoliasearch-magento,代码行数:43,代码来源:Data.php

示例12: _prepareData

 /**
  * @param Mage_Catalog_Model_Category $category
  * @param Mage_Catalog_Model_Resource_Category_Collection $categoryCollection
  * @return array
  */
 protected function _prepareData($category, $categoryCollection = null)
 {
     return array("id" => $category->getId(), "path" => $category->getData("path"), self::PATH_NAMES => $this->_getNames($category->getPathIds(), $categoryCollection));
 }
开发者ID:sereban,项目名称:magento-marketo-integration,代码行数:9,代码来源:Path.php


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