本文整理汇总了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;
}