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