- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
when we click to a product now we have
how I can change to
www.mysite.com/sometext/product.html
Thanks in advance..
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can modify the url rewrite rule as you wanted in catalog->url rewrite management.
If you are looking for an automatic solution, rewrite Mage_Catalog_Model_Url::getProductRequestPath method,
if ($category->getLevel() > 1) { // To ensure, that category has path either from attribute or generated now $this->_addCategoryUrlPath($category); $categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(), false, $storeId); $requestPath = $categoryUrl . '/' . $urlKey; } else { $requestPath = 'something/' . $urlKey; }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can modify the url rewrite rule as you wanted in catalog->url rewrite management.
If you are looking for an automatic solution, rewrite Mage_Catalog_Model_Url::getProductRequestPath method,
if ($category->getLevel() > 1) { // To ensure, that category has path either from attribute or generated now $this->_addCategoryUrlPath($category); $categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(), false, $storeId); $requestPath = $categoryUrl . '/' . $urlKey; } else { $requestPath = 'something/' . $urlKey; }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Product Page
Is /sometext/ is your category name ? If so then you can enable it from System >> Configuration >> Catalog >> Search Engine Optimization. Choose Yes for "Use categories path for product URLs".
But if not like any text other text want to insert then you can manage it through URL rewrite Management. Don't do any change into code level its not good practice.
Menu - Catalog >> URL Rewrite Management
1. Click to add new url and choose Products from create URL rewrite.
2. select Or search your product and if ask for category selection then skip that part.
3. Over url rewrite form add your custom url into Request Path field. (E.x - sometext/product.html) And save it and clear cache and reindex.
Now check same on frontend it should be work.
Hope it helps you, Good luck
Magento Programmer | Was my answer helpful? You can accept it as a solution.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Product Page
Why is rewirting code not a good practice? Imagin if he has millions of products to maintain, its not easy to update rewrite rules menually and not missing any rules.
But of course if he only need to modify a few rules, he can use the url write manager like I mentioned before.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Product Page
Thanks alot!!