问题描述:

How to add url prefix according to the level of categories

Example :-

example.com/h/lvl-1-categories

example.com/s/lvl-2-categories

Etc

Thanks

网友答案:

Solved it :

Copied

/app/code/core/Mage/Catalog/Model/Url.php

to

/app/code/local/Mage/Catalog/Model/Url.php

in Url.php find the lines

    if (null === $parentPath) {
        $parentPath = $this->getResource()->getCategoryParentPath($category);
    }
    elseif ($parentPath == '/') {

        $parentPath = '';

   }

and replace with

//        if (null === $parentPath) {
//            $parentPath = $this->getResource()->getCategoryParentPath($category);
//        }
//        elseif ($parentPath == '/') {
        if($category->getLevel() > 2){
            $parentPath = 'c/';
        }else{
            $parentPath = 'h/';
        }

//        }

Modified the answer from http://www.magentocommerce.com/boards/viewthread/32328/

相关阅读:
Top