cancel
Showing results for 
Search instead for 
Did you mean: 

Product Page

SOLVED

Product Page

Hi all,

when we click to a product now we have

www.mysite.com/product.html

 

how I can change to

 

www.mysite.com/sometext/product.html

 

Thanks in advance..

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Product Page

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;
        }

View solution in original post

4 REPLIES 4

Re: Product Page

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;
        }

Re: Product Page

@Stefy

 

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 Smiley Happy

 

 

 

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.

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.

Re: Product Page

Thanks alot!!