i just tried to make my product_info.php urls customizable, as i dont like that the url is gonna change once you change the product name just a little
Modifications are made to work with the rewrite functionality (where you need to have rewrite rules in htaccess).
page module index.php still needs to be modified to have the customized category urls there as well.
categories.php in admin would need a modification if you want to edit the seo url database fields from there.
based on v208 https://apps.oscommerce.com/Hj4y0&ultimate-seo-urls-5-for-responsive-oscom
looks good so far for product_info.php, but
a) i could need some help with page module index.php to show the categories with the customized urls also.
b) will that break any of the usu5 modules functionality?
add fields to database
=======================================
in table categories_description
add field categories_seo_url (varchar 255)
in table products_description
add field products_seo_url (varchar 255)
modify page modules
=======================================
in /includes/modules/ultimate_seo_urls5/page_modules/product_info.php
find this:
protected $dependencies = array( 'products_id' => array( 'marker' => '-p-',
'query' => "SELECT pd.products_name, m.manufacturers_name, cd.categories_name, p.products_model, p2c.categories_id FROM products_description pd INNER JOIN products_to_categories p2c ON p2c.products_id = pd.products_id INNER JOIN products p ON pd.products_id = p.products_id LEFT JOIN manufacturers m ON m.manufacturers_id = p.manufacturers_id INNER JOIN categories_description cd ON p2c.categories_id = cd.categories_id AND cd.language_id=':languages_id' WHERE pd.products_id=':pid' AND pd.language_id=':languages_id' LIMIT 1",
'to_replace' => array( ':languages_id', ':pid' ) ) );
and replace with this:
protected $dependencies = array( 'products_id' => array( 'marker' => '-p-',
'query' => "SELECT pd.products_seo_url, pd.products_name, m.manufacturers_name, cd.categories_seo_url, cd.categories_name, p.products_model, p2c.categories_id FROM products_description pd INNER JOIN products_to_categories p2c ON p2c.products_id = pd.products_id INNER JOIN products p ON pd.products_id = p.products_id LEFT JOIN manufacturers m ON m.manufacturers_id = p.manufacturers_id INNER JOIN categories_description cd ON p2c.categories_id = cd.categories_id AND cd.language_id=':languages_id' WHERE pd.products_id=':pid' AND pd.language_id=':languages_id' LIMIT 1",
'to_replace' => array( ':languages_id', ':pid' ) ) );
right after:
// manufacturers_name is gained through a left join and may not exist
array_key_exists( 'manufacturers_name', $details ) ? $text_types['b'] = $details['manufacturers_name'] : null;
add:
//if we have a products_seo_url, we use that string instead of products_name
if (!empty($details['products_seo_url'])) {
$text_types['p'] = $details['products_seo_url'];
}
//if we have a categories_seo_url, we use that string instead of categories_name
if (!empty($details['categories_seo_url'])) {
$text_types['c'] = $details['categories_seo_url'];
}
Removing .html from the rewrite URLs
=======================================
in /includes/modules/ultimate_seo_urls5/uri_modules/path_rewrite.php
and
in /includes/modules/ultimate_seo_urls5/uri_modules/rewrite.php
replace:
if ( false === strpos( Usu_Main::i()->getVar( 'request_uri' ), '.html' ) ) { // path_rewrite seo url must have .html
return false;
}
with:
/*
if ( false === strpos( Usu_Main::i()->getVar( 'request_uri' ), '.html' ) ) { // path_rewrite seo url must have .html
return false;
}
*/
find:
return usu5_multi_language( $separator = 'right' ) . $text . $seperator . $value . '.html';
and replace it with:
return usu5_multi_language( $separator = 'right' ) . $text . $seperator . $value;
in /.htaccess
replace:
RewriteRule ^([a-z0-9/-]+)-p-([0-9]+).html$ product_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-c-([0-9_]+).html$ index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-m-([0-9]+).html$ index.php [NC,L,QSA]
with:
RewriteRule ^([a-z0-9/-]+)-p-([0-9]+)$ product_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-c-([0-9_]+)$ index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-m-([0-9]+)$ index.php [NC,L,QSA]