Hi friends,
Today I would like to tell you, how you can remove parent category path from sub category url in Magento.
To do so, Go to:
app/code/core/Mage/Catalog/Model folder and copy Url.php file to override it in your local package.
Open this file (Url.php) and find the following:
public function getCategoryRequestPath($category, $parentPath)
With in this function, find the following code:
// if (null === $parentPath) {
// $parentPath = $this->getResource()->getCategoryParentPath($category);
// }
// elseif ($parentPath == '/') {
$parentPath = '';
// }
Today I would like to tell you, how you can remove parent category path from sub category url in Magento.
To do so, Go to:
app/code/core/Mage/Catalog/Model folder and copy Url.php file to override it in your local package.
Open this file (Url.php) and find the following:
public function getCategoryRequestPath($category, $parentPath)
With in this function, find the following code:
if (null === $parentPath) {
$parentPath = $this->getResource()->getCategoryParentPath($category);
}
elseif ($parentPath == '/') {
$parentPath = '';
}
and comment it like this:// if (null === $parentPath) {
// $parentPath = $this->getResource()->getCategoryParentPath($category);
// }
// elseif ($parentPath == '/') {
$parentPath = '';
// }
and save the file.
Note: It should be noted that the code $parentPath = ''; in else part should not be commented.
Now login to admin panel of your site, and go to:
System->Config->Index Management and click on "select all" then select Reindex Data from the Action Dropdown, then click on submit.
That's all.. Enjoy.. :)