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


PHP Mage_Catalog_Model_Category::getPath方法代码示例

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


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

示例1: _buildCategoryTree

 /**
  * Take a Mage_Catalog_Model_Category object and build a category tree from
  * the child leaf to the root of the category (root > inner child > inner most child)
  * @param Mage_Catalog_Model_Category $category the inner most child
  * @return string
  */
 protected function _buildCategoryTree(Mage_Catalog_Model_Category $category)
 {
     $collecton = $this->_getCategoriesByIds(explode('/', $category->getPath()));
     $categories = array();
     foreach ($collecton as $cat) {
         $categories[] = $cat->getName();
     }
     return implode(' > ', array_filter($categories));
 }
开发者ID:adamhobson,项目名称:magento-eems-affiliate,代码行数:15,代码来源:Product.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: getCategoryPathAsString

 /**
  * Get category path as "-" separated string.
  *
  * @param Mage_Catalog_Model_Category $category
  * @return string
  */
 public function getCategoryPathAsString(Mage_Catalog_Model_Category $category)
 {
     // Extract the categry IDs from the category path
     $categoryPathIds = explode('/', $category->getPath());
     // Exclude the root category
     array_shift($categoryPathIds);
     // Get the name of each category in the category path
     $categoryNames = array();
     foreach ($categoryPathIds as $categoryId) {
         $categoryNames[] = Mage::getModel('catalog/category')->load($categoryId)->getName();
     }
     // Implode the categories, separated by a " - ", e.g. "Category X - Subcategory Y - Subcategory Z"
     $categoryPath = implode(' - ', $categoryNames);
     return $categoryPath;
 }
开发者ID:samuelecarpene,项目名称:MobWeb_AdWordsRemarketingTags,代码行数:21,代码来源:Data.php

示例4: _fastIndexerLoadNodes

 /**
  * Load nodes by parent id
  *
  * @param Mage_Catalog_Model_Category|int $parentNode
  * @param integer                         $recursionLevel
  * @param integer                         $storeId
  *
  * @return Mage_Catalog_Model_Resource_Category_Flat
  */
 protected function _fastIndexerLoadNodes($parentNode = null, $recursionLevel = 0, $storeId = 0)
 {
     $_conn = $this->_getReadAdapter();
     $startLevel = 1;
     $parentPath = '';
     if ($parentNode instanceof Mage_Catalog_Model_Category) {
         $parentPath = $parentNode->getPath();
         $startLevel = $parentNode->getLevel();
     } elseif (is_numeric($parentNode)) {
         $selectParent = $_conn->select()->from($this->getMainStoreTable($storeId))->where('entity_id = ?', $parentNode)->where('store_id = ?', $storeId);
         $parentNode = $_conn->fetchRow($selectParent);
         if ($parentNode) {
             $parentPath = $parentNode['path'];
             $startLevel = $parentNode['level'];
         }
     }
     $select = $_conn->select()->from(array('main_table' => $this->getMainStoreTable($storeId)), array('entity_id', new Zend_Db_Expr('main_table.' . $_conn->quoteIdentifier('name')), new Zend_Db_Expr('main_table.' . $_conn->quoteIdentifier('path')), 'is_active', 'is_anchor', 'main_table.url_path as request_path'))->where('main_table.is_active = ?', '1')->where('main_table.include_in_menu = ?', '1')->order('main_table.position');
     if ($parentPath) {
         $select->where($_conn->quoteInto("main_table.path like ?", "{$parentPath}/%"));
     }
     if ($recursionLevel != 0) {
         $levelField = $_conn->quoteIdentifier('level');
         $select->where($levelField . ' <= ?', $startLevel + $recursionLevel);
     }
     $inactiveCategories = $this->getInactiveCategoryIds();
     if (!empty($inactiveCategories)) {
         $select->where('main_table.entity_id NOT IN (?)', $inactiveCategories);
     }
     // Allow extensions to modify select (e.g. add custom category attributes to select)
     Mage::dispatchEvent('catalog_category_flat_loadnodes_before', array('select' => $select));
     $arrNodes = $_conn->fetchAll($select);
     $nodes = array();
     foreach ($arrNodes as $node) {
         $node['id'] = $node['entity_id'];
         $nodes[$node['id']] = Mage::getModel('catalog/category')->setData($node);
     }
     return $nodes;
 }
开发者ID:ThomasNegeli,项目名称:Magento-FastIndexer,代码行数:47,代码来源:FlatAbstract.php

示例5: getChildren

 /**
  * Return children ids of category
  *
  * @param Mage_Catalog_Model_Category $category
  * @param boolean $recursive
  * @return array
  */
 public function getChildren($category, $recursive = true)
 {
     $attributeId = (int) $this->_getIsActiveAttributeId();
     $backendTable = $this->getTable(array($this->getEntityTablePrefix(), 'int'));
     $adapter = $this->_getReadAdapter();
     $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value');
     $bind = array('attribute_id' => $attributeId, 'store_id' => $category->getStoreId(), 'scope' => 1, 'c_path' => $category->getPath() . '/%');
     $select = $this->_getReadAdapter()->select()->from(array('m' => $this->getEntityTable()), 'entity_id')->joinLeft(array('d' => $backendTable), 'd.attribute_id = :attribute_id AND d.store_id = 0 AND d.entity_id = m.entity_id', array())->joinLeft(array('c' => $backendTable), 'c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = m.entity_id', array())->where($checkSql . ' = :scope')->where($adapter->quoteIdentifier('path') . ' LIKE :c_path');
     if (!$recursive) {
         $select->where($adapter->quoteIdentifier('level') . ' <= :c_level');
         $bind['c_level'] = $category->getLevel() + 1;
     }
     return $adapter->fetchCol($select, $bind);
 }
开发者ID:nemphys,项目名称:magento2,代码行数:21,代码来源:Category.php

示例6: getChildren

 /**
  * Return children ids of category
  *
  * @param Mage_Catalog_Model_Category $category
  * @param integer $level
  * @return array
  */
 public function getChildren($category, $recursive = true, $isActive = true)
 {
     $select = $this->_getReadAdapter()->select()->from($this->getMainStoreTable($category->getStoreId()), 'entity_id')->where('path LIKE ?', "{$category->getPath()}/%");
     if (!$recursive) {
         $select->where('level <= ?', $category->getLevel() + 1);
     }
     if ($isActive) {
         $select->where('is_active = ?', '1');
     }
     $_categories = $this->_getReadAdapter()->fetchAll($select);
     $categoriesIds = array();
     foreach ($_categories as $_category) {
         $categoriesIds[] = $_category['entity_id'];
     }
     return $categoriesIds;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:23,代码来源:Resource_Eav_Mysql4_Category_Flat.php

示例7: _isCategoryAllowed

 /**
  * Check whether specified category is allowed
  *
  * @param Mage_Catalog_Model_Category $category
  * @return bool
  */
 protected function _isCategoryAllowed($category)
 {
     if (!$category->getId()) {
         return false;
     }
     $categoryPath = $category->getPath();
     foreach ($this->_role->getAllowedRootCategories() as $rootPath) {
         if ($categoryPath === $rootPath || 0 === strpos($categoryPath, "{$rootPath}/")) {
             return true;
         }
     }
     return false;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:19,代码来源:Controllers.php

示例8: getChildrenAmount

 /**
  * Get count of active/not active children categories
  *
  * @param Mage_Catalog_Model_Category $category
  * @param bool $isActiveFlag
  * @return int
  */
 public function getChildrenAmount($category, $isActiveFlag = true)
 {
     $storeId = Mage::app()->getStore()->getId();
     $attributeId = $this->_getIsActiveAttributeId();
     $table = $this->getTable(array($this->getEntityTablePrefix(), 'int'));
     $adapter = $this->_getReadAdapter();
     $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value');
     $bind = array('attribute_id' => $attributeId, 'store_id' => $storeId, 'active_flag' => $isActiveFlag, 'c_path' => $category->getPath() . '/%');
     $select = $adapter->select()->from(array('m' => $this->getEntityTable()), array('COUNT(m.entity_id)'))->joinLeft(array('d' => $table), 'd.attribute_id = :attribute_id AND d.store_id = 0 AND d.entity_id = m.entity_id', array())->joinLeft(array('c' => $table), "c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = m.entity_id", array())->where('m.path LIKE :c_path')->where($checkSql . ' = :active_flag');
     return $this->_getReadAdapter()->fetchOne($select, $bind);
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:18,代码来源:Category.php

示例9: getChildren

 /**
  * Return children ids of category
  *
  * @param Mage_Catalog_Model_Category $category
  * @param boolean $recursive
  * @return array
  */
 public function getChildren($category, $recursive = true)
 {
     $attributeId = $this->_getIsActiveAttributeId();
     $select = $this->_getReadAdapter()->select()->from(array('m' => $this->getEntityTable()), 'entity_id')->joinLeft(array('d' => $this->getEntityTable() . '_int'), "d.attribute_id = '{$attributeId}' AND d.store_id = 0 AND d.entity_id = m.entity_id", array())->joinLeft(array('c' => $this->getEntityTable() . '_int'), "c.attribute_id = '{$attributeId}' AND c.store_id = '{$category->getStoreId()}' AND c.entity_id = m.entity_id", array())->where('(IFNULL(c.value, d.value) = ?)', '1')->where('path LIKE ?', "{$category->getPath()}/%");
     if (!$recursive) {
         $select->where('level <= ?', $category->getLevel() + 1);
     }
     $_categories = $this->_getReadAdapter()->fetchAll($select);
     $categoriesIds = array();
     foreach ($_categories as $_category) {
         $categoriesIds[] = $_category['entity_id'];
     }
     return $categoriesIds;
     //        $this->_getTree()->load();
     //        return $this->_getTree()->getChildren($category->getId(), false);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:23,代码来源:Resource_Eav_Mysql4_Category.php

示例10: getChildrenAmount

 /**
  * Get count of active/not active children categories
  *
  * @param   Mage_Catalog_Model_Category $category
  * @param   bool $isActiveFlag
  * @return  int
  */
 public function getChildrenAmount($category, $isActiveFlag = true)
 {
     $storeId = Mage::app()->getStore()->getId();
     $attributeId = $this->_getIsActiveAttributeId();
     $table = Mage::getSingleton('core/resource')->getTableName('catalog/category') . '_int';
     $select = $this->_getReadAdapter()->select()->from(array('m' => $this->getEntityTable()), array('COUNT(m.entity_id)'))->joinLeft(array('d' => $table), "d.attribute_id = '{$attributeId}' AND d.store_id = 0 AND d.entity_id = m.entity_id", array())->joinLeft(array('c' => $table), "c.attribute_id = '{$attributeId}' AND c.store_id = '{$storeId}' AND c.entity_id = m.entity_id", array())->where('m.path like ?', $category->getPath() . '/%')->where('(IFNULL(c.value, d.value) = ?)', $isActiveFlag);
     return $this->_getReadAdapter()->fetchOne($select);
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:15,代码来源:Category.php

示例11: _applyEventToCategory

 /**
  * Apply event to category
  *
  * @param Varien_Data_Tree_Node|Mage_Catalog_Model_Category $category
  * @param Varien_Data_Collection $eventCollection
  * @return Enterprise_CatalogEvent_Model_Observer
  */
 protected function _applyEventToCategory($category, Varien_Data_Collection $eventCollection)
 {
     foreach (array_reverse($this->_parseCategoryPath($category->getPath())) as $categoryId) {
         // Walk through category path, search event for category
         $event = $eventCollection->getItemByColumnValue('category_id', $categoryId);
         if ($event) {
             $category->setEvent($event);
             return $this;
         }
     }
     return $this;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:19,代码来源:Observer.php

示例12: catalogCategorySaveBefore

 /**
  * Validate catalog category save
  *
  * @param Mage_Catalog_Model_Category $model
  */
 public function catalogCategorySaveBefore($model)
 {
     if (!$model->getId()) {
         return;
     }
     // No saving to wrong stores
     if (!$this->_role->hasStoreAccess($model->getStoreIds())) {
         $this->_throwSave();
     }
     // No saving under disallowed root categories
     $categoryPath = $model->getPath();
     $allowed = false;
     foreach ($this->_role->getAllowedRootCategories() as $rootPath) {
         if ($categoryPath != $rootPath) {
             if (0 === strpos($categoryPath, "{$rootPath}/")) {
                 $allowed = true;
             }
         } else {
             if ($this->_role->hasExclusiveCategoryAccess($rootPath)) {
                 $allowed = true;
             }
         }
         if ($allowed) {
             break;
         }
     }
     if (!$allowed) {
         $this->_throwSave();
     }
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:35,代码来源:Models.php

示例13: getRedirectForCategory

 /**
  * Get a parent category for a (disabled) category
  *
  * @param Mage_Catalog_Model_Category $category
  * @return string Redirect url
  */
 protected function getRedirectForCategory(Mage_Catalog_Model_Category $category)
 {
     $url = Mage::getBaseUrl();
     $path = array_reverse(explode('/', $category->getPath()));
     $blacklist = explode(',', Mage::getStoreConfig(self::XML_PATH_REDIRECT_BLACKLIST_CATEGORY_IDS));
     array_walk($blacklist, create_function('&$val', '$val = trim($val);'));
     $blacklist = array_filter($blacklist);
     $root_id = Mage::app()->getGroup()->getRootCategoryId();
     foreach ($path as $id) {
         // When category root is reached return base url
         if ($id == $root_id) {
             return $url;
         }
         // Skip blacklisted categories
         if (in_array($id, $blacklist)) {
             continue;
         }
         $category = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('entity_id', $id)->addUrlRewriteToResult()->addIsActiveFilter()->setPageSize(1)->setCurPage(1)->getFirstItem();
         if ($category->getEntityId()) {
             return $url . $category->getRequestPath();
         }
     }
     return $url;
 }
开发者ID:steffen-wirth,项目名称:Loewenstark_Seo,代码行数:30,代码来源:Observer.php


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