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


PHP Mage_Catalog_Model_Category::getParentUrl方法代码示例

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


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

示例1: _reindexCategoryUrlKey

 protected function _reindexCategoryUrlKey(Mage_Catalog_Model_Category $category, Mage_Core_Model_Store $store)
 {
     $requestPath = trim($category->getParentUrl(), '/');
     if (Mage::getStoreConfig('catalog/seo/category_use_parent_category')) {
         $requestPath = (!empty($requestPath) ? $requestPath . '/' : '') . $category->getUrlKey();
     } else {
         $requestPath = $category->getUrlKey();
     }
     $requestPath = $this->_cutRequestPath($requestPath);
     $urlKeyValue = $this->_getUrlKeyAttributeValueId($category, $store);
     if (empty($urlKeyValue) && empty($urlKeyValue['value_id'])) {
         $category = $this->_setUrlKeyForDefaultStore($category, $store);
         $urlKeyValue = $this->_getUrlKeyAttributeValueId($category, $store);
     }
     $valueId = $urlKeyValue['value_id'];
     $rewriteRow = $this->_getRewrite($requestPath, $store->getId());
     if (!$rewriteRow || $rewriteRow['value_id'] != $valueId) {
         $rewriteForValueId = $this->_getRewriteForValueId($store->getId(), $valueId);
         $suffix = trim(str_replace($requestPath, '', $category->getRequestPath()), '-');
         $requestPathIncrement = (int) $this->_getRewriteRequestIncrement($requestPath, $store);
         if (!$rewriteForValueId || !preg_match('#^(\\d)+$#', $suffix) || $suffix > $requestPathIncrement) {
             if ($rewriteRow && $rewriteRow['value_id'] != $valueId) {
                 $requestPath .= '-' . ++$requestPathIncrement;
             }
             $category = $this->_saveRewrite($category, $store, $requestPath, $valueId);
         }
     }
     $this->_indexedCategoryIds[$store->getId()][$category->getId()] = 1;
     return $category;
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:30,代码来源:Mnm_ExcParentCatPathFromSubCatUrls_Model_Catalog_Index_Action_Url_Rewrite_Category_Refresh.php

示例2: _reindexCategoryUrlKey

 /**
  * Write category url_key into enterprise_url_rewrite table
  *
  * @param Mage_Catalog_Model_Category $category
  * @param Mage_Core_Model_Store $store
  * @return Mage_Catalog_Model_Category
  */
 protected function _reindexCategoryUrlKey(Mage_Catalog_Model_Category $category, Mage_Core_Model_Store $store)
 {
     $requestPath = trim($category->getParentUrl(), '/');
     $requestPath = (!empty($requestPath) ? $requestPath . '/' : '') . $category->getUrlKey();
     $requestPath = $this->_cutRequestPath($requestPath);
     $urlKeyValue = $this->_getUrlKeyAttributeValueId($category, $store);
     /*
      * if this category created on store view level, we should write default url key for this category,
      * or this category will be unaccessible from frontend
      */
     if (empty($urlKeyValue) && empty($urlKeyValue['value_id'])) {
         $category = $this->_setUrlKeyForDefaultStore($category, $store);
         //get url key value id from backend table after changes
         $urlKeyValue = $this->_getUrlKeyAttributeValueId($category, $store);
     }
     $valueId = $urlKeyValue['value_id'];
     /**
      * Check if we should insert rewrite into table
      */
     $rewriteRow = $this->_getRewrite($requestPath, $store->getId());
     if (!$rewriteRow || $rewriteRow['value_id'] != $valueId) {
         //get current url path from enterprise_url_rewrite
         $rewriteForValueId = $this->_getRewriteForValueId($store->getId(), $valueId);
         $suffix = trim(str_replace($requestPath, '', $category->getRequestPath()), '-');
         /*
          * theoretically we may face with situation when several categories have url_key like:
          * id url_key request path
          * 1  abc     abc
          * 2  abc     abc-1
          * 3  abc     abc-2
          * and we should reindex category with id 2, we can't be sure should we add prefix or not
          * so workaround with regexp cover most cases of this problem
          */
         $requestPathIncrement = (int) $this->_getRewriteRequestIncrement($requestPath, $store);
         if (!$rewriteForValueId || !preg_match('#^(\\d)+$#', $suffix) || $suffix > $requestPathIncrement) {
             if ($rewriteRow && $rewriteRow['value_id'] != $valueId) {
                 $requestPath .= '-' . ++$requestPathIncrement;
             }
             $category = $this->_saveRewrite($category, $store, $requestPath, $valueId);
             // clean full page cache for category
         }
     }
     // save id of already indexed category into list
     $this->_indexedCategoryIds[$store->getId()][$category->getId()] = 1;
     return $category;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:53,代码来源:Refresh.php


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