當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。