

Want to get the manufacturer name into the product_info url on ultimate SEO urls for OsCommerce? Here's how!
It's handy on some shops to have the brand name in the Search Engine Friendly (SEF) url for the Ultimate SEO Url contribution in OsCommerce. However, this feature isn't supported out of the box, it is however a simple code change.
Step 1. Open includes/classes/seo.class.php |
---|
Add the following function to the end of the class before the
} # end class closing brackets... |
function get_manufacturer_name_from_product(&$cID){ $this->performance['NUMBER_QUERIES']++; $sql = "SELECT m.manufacturers_name, m.manufacturers_id FROM ".TABLE_MANUFACTURERS." m LEFT OUTER JOIN ".TABLE_PRODUCTS." p ON m.manufacturers_id = p.manufacturers_id WHERE p.products_id = '".(int)$cID."' LIMIT 1"; $result = $this->DB->FetchArray( $this->DB->Query( $sql ) ); $mName = $this->not_null($result['manufacturers_name']) ? $result['manufacturers_name'] : $result['manufacturers_name']; $this->cache['MANUFACTURERS'][$full_cPath] = $mName; return $return; |
Step 2. Replace the following |
In the function called 'parse_parameters' replace the follow code after line with "case 'products_id':" |
switch(true){ case ( $page == FILENAME_PRODUCT_INFO && !$this->is_attribute_string($p2[1]) ): $url = $this->make_url($page, $this->get_product_name($p2[1]), $p2[0], $p2[1], '.html', $separator); $this->ValidateName($url, "p", $p2[1], $connection, $separator); break; case ( $page == FILENAME_PRODUCT_REVIEWS ): $url = $this->make_url($page, $this->get_product_name($p2[1]), 'products_id_review', $p2[1], '.html', $separator); $this->ValidateName($url, "pr", $p2[1], $connection, $separator); break; case ( $page == FILENAME_PRODUCT_REVIEWS_INFO ): $url = $this->make_url($page, $this->get_product_name($p2[1]), 'products_id_review_info', $p2[1], '.html', $separator); $this->ValidateName($url, "pw", $p2[1], $connection, $separator); break; default: $container[$p2[0]] = $p2[1]; break; } # end switch break; |
with the following: |
switch(true){ case ( $page == FILENAME_PRODUCT_INFO && !$this->is_attribute_string($p2[1]) ): $url = $this->make_url($page, $this->get_manufacturer_name_from_product($p2[1])."-".$this->get_product_name($p2[1]), $p2[0], $p2[1], '.html', $separator); $this->ValidateName($url, "p", $p2[1], $connection, $separator); break; case ( $page == FILENAME_PRODUCT_REVIEWS ): $url = $this->make_url($page, $this->get_manufacturer_name_from_product($p2[1])."-".$this->get_product_name($p2[1]), 'products_id_review', $p2[1], '.html', $separator); $this->ValidateName($url, "pr", $p2[1], $connection, $separator); break; case ( $page == FILENAME_PRODUCT_REVIEWS_INFO ): $url = $this->make_url($page, $this->get_manufacturer_name_from_product($p2[1])."-".$this->get_product_name($p2[1]), 'products_id_review_info', $p2[1], '.html', $separator); $this->ValidateName($url, "pw", $p2[1], $connection, $separator); break; default: $container[$p2[0]] = $p2[1]; break; } # end switch break; |
Step 3. Clear the cache and reset sitemaps |
In the admin under the SEO Urls, clear/reset the cache. If running sitemaps, regenerate the sitemap and ping Google, same goes for Froogle if running feeds.
If it's a very very well aged and well ranked site you may wish to create 301 redirects for all the old SEF urls to the new SEF urls if required. |
Comments
Thank you for the info
I got a bug in Ultimate SEO URL
I got a bad redirection on manufacturers_id
Just dont know what to do
Regards
Hi Pisco, Need to see the bug
Hi Pisco,
Need to see the bug to help! :) Typically the first port of call with SEO Urls is to check that you have the right directory name (especially if using a sub directory!) in the .htaccess. Then check you have all the required PHP modules enabled. After that, it's time to start digging into the code! :)
Cheers,
Graeme.
Post new comment