本文整理匯總了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;
}