url rewriting - Remove parent categories from subcategory in URLs in Magento 1.9.2.3 -
magento version 1.9.2.3.
i have tried following solution doesn't work me.
step 1: go app/code/core/mage/catalog/model/url.php copy file app/code/local/mage/catalog/model/url.php because core magento file have copy file app/code/local.
step 2: search getcategoryrequestpath($category, $parentpath) around line 698 in magento ver. 1.9.1.0
step 3: search if (null === $parentpath) around line 717 , comment line below:
/* if (null === $parentpath) { $parentpath = $this->getresource()->getcategoryparentpath($category); } elseif ($parentpath == '/'){*/ $parentpath = ''; //do not comment line //}
step 4: go magento admin , clear cache system->cache management , reindex system->index management data.
step 5: refresh browser cache , navigate again see sub category in url not parent category http://www.abcxyz.com/test-category-level-1-3.html - see more at: http://www.expertwebadvisor.com/remove-parent-category-path-from-sub-category-url-in-magento/#sthash.cy3hvxww.dpuf
i have tried solution doesn't work me.
suppose want remove parent category path url such url-> www.domain.com/cat1/cat2 www.domain.com/cat2
usage :
go magento admin panel -> system -> configuration -> catalog -> seo options select yes or no "use parent category path category urls" refresh category url index.
option yes => www.domain.com/cat1/cat2
option no => www.domain.com/cat2
help me if have solution
your first alternative needs work. check if override "mage_catalog_model_url" working fine. try die() within method.
i have did particular category id. need remove category id '4' every category url. , below code it:
public function getcategoryrequestpath($category, $parentpath) { $storeid = $category->getstoreid(); $idpath = $this->generatepath('id', null, $category); $suffix = $this->getcategoryurlsuffix($storeid); if (isset($this->_rewrites[$idpath])) { $this->_rewrite = $this->_rewrites[$idpath]; $existingrequestpath = $this->_rewrites[$idpath]->getrequestpath(); } if ($category->geturlkey() == '') { $urlkey = $this->getcategorymodel()->formaturlkey($category->getname()); } else { $urlkey = $this->getcategorymodel()->formaturlkey($category->geturlkey()); } $categoryurlsuffix = $this->getcategoryurlsuffix($category->getstoreid()); if (null === $parentpath && $category->getparentid() != 4) { $parentpath = $this->getresource()->getcategoryparentpath($category); } elseif($category->getparentid() == 4){ $parentpath = ''; } elseif ($parentpath == '/') { $parentpath = ''; } $parentpath = mage::helper('catalog/category')->getcategoryurlpath($parentpath, true, $category->getstoreid()); $requestpath = $parentpath . $urlkey . $categoryurlsuffix; if (isset($existingrequestpath) && $existingrequestpath == $requestpath . $suffix) { return $existingrequestpath; } if ($this->_deleteoldtargetpath($requestpath, $idpath, $storeid)) { return $requestpath; } return $this->getunusedpath($category->getstoreid(), $requestpath, $this->generatepath('id', null, $category) ); }
Comments
Post a Comment