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


PHP Mage_Catalog_Model_Category::getUrlKey方法代码示例

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


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

 /**
  * Check unique url_key value in catalog_category_entity_url_key table.
  *
  * @param Mage_Catalog_Model_Category $object
  * @return Mage_Catalog_Model_Category_Attribute_Backend_Urlkey
  * @throws Mage_Core_Exception
  */
 protected function _validateEntityUrl($object)
 {
     $connection = $object->getResource()->getReadConnection();
     $select = $connection->select()->from($this->getAttribute()->getBackendTable(), array('count' => new Zend_Db_Expr('COUNT(\'value_id\')')))->where($connection->quoteInto('entity_id <> ?', $object->getId()))->where($connection->quoteInto('value = ?', $object->getUrlKey()));
     $result = $connection->fetchOne($select);
     if ((int) $result) {
         throw new Mage_Core_Exception(Mage::helper('catalog')->__("Category with the '%s' url_key attribute already exists.", $object->getUrlKey()));
     }
     return $this;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:17,代码来源:Urlkey.php

示例3: isCategoryAcceptable

 /**
  * Checks if a category matches criteria: active && url_key not null && included in menu if it has to
  */
 protected static function isCategoryAcceptable(Mage_Catalog_Model_Category $category = null, $mustBeIncludedInNavigation = true)
 {
     if (!$category->getIsActive() || is_null($category->getUrlKey()) || $mustBeIncludedInNavigation && !$category->getIncludeInMenu()) {
         return false;
     }
     return true;
 }
开发者ID:liemnv,项目名称:Groupon-Clone-On-Magento,代码行数:10,代码来源:Data.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: 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

示例6: _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

示例7: _getUrlKey

 /**
  * Get url key for category data
  *
  * @param Mage_Catalog_Model_Category $category
  * @return string
  */
 public function _getUrlKey($category)
 {
     if ($category instanceof Mage_Catalog_Model_Category) {
         $urlKey = $category->getUrlKey();
     } else {
         $urlKey = $this->_getCategoryInstance()->setData($category->getData())->getUrlKey();
     }
     return $urlKey;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:15,代码来源:Navigation.php


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