1

I want to make URL for SEO optimization.

My URL is: supplements.html?manufacturer=166
I want URL like: supplements/manufacturer/scivation.html

(scivation is manufacturerfor id 166 and supplementsis category and manufacturer is attribute)

Any help would be greatly appreciated.Thanks in advance.

Francis Kim
  • 4,235
  • 4
  • 36
  • 51

1 Answers1

0

Because 'supplements' is a category (which changes) it's going to be more difficult to use a writing rule without hard coding. One possible solution is to use Mage::getModel('core/url_rewrite') (example) to create a route for each (you may run into issues using this method)

Another solution would be to change the url format

/manufacturer/supplements/scivation.html

Then create a custom module

config.xml

<global>
    <rewrite>
      <fancy_url>
            <from><![CDATA[/manufacturer\/(.*)/(.*)/]]></from>
            <to><![CDATA[manufacturer/index/processroute/manufacturername/$2/]]></to>
            <complete>1</complete>
       </fancy_url>
    <rewrite>
</global>
<frontend>
    <routers>
        <tagseo>
            <use>standard</use>
            <args>
                <frontName>customcategory</frontName>
            </args>
        </tagseo>
    </routers>

class MageIgniter_Manufacturer_IndexController extends Mage_Core_Controller_Front_Action
{
     public function processRoute(){
           print_r($requestUri = Mage::app()->getRequest()->getRequestUri()); //supplements/scivation.html
           print_r($this->getRequest()->getParam('manufacturername')); // scivation.html
           print_r($this->getRequest())
           // do you custom logic here base on about request path explode('/', trim($requestUri,'/'))

           //lookup the attribute_id from attribute name 
           //if attribute_id found then try 
           //$this->_forward(string $action, [string|null $controller = null], [string|null $module = null], [ $params = null])
           // to the catalog page
           // else  $this->_forward('defaultNoRoute');


     }
     ...

Read more @

Simple URL Rewrite Using Magento xml

Magento Router Url - Need Hyphnated Path Name

Magento V1.7 Grid View - Add manufacturer attribute to view

Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62