Hi David,
Is it possible to use .htaccess to add a custom field to the product url.
I have removed the .html using anther mod so my product url looks like
http://example.com/product/adidas-Pants
I would like to add my custom field of colour to the trialing end like this
http://example.com/product/adidas-Pants-black
Thanks
Richard
How about adding
<?php
print $mainProduct["id"];
?>
Im trying to create unique URL's from my datafeed
Hi,
Sure - id is already selected so you can use in place of colour in the replacement to includes/tapestry.php eg:
return $config_baseHREF."product/".urlencode(tapestry_hyphenate($product["normalised_name"]))."-(".$product["id"].")";
Cheers,
David.
--
PriceTapestry.com
How do i remove the brackets for the ID, im assuuming I change .htaccess
RewriteRule ^product/(.*)-\((.*)\)$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [B,L]
Hi Richard,
With the change to includes/tapestry.php as follows:
return $config_baseHREF."product/".urlencode(tapestry_hyphenate($product["normalised_name"]))."-".$product["id"];
Have a go with the RewriteRule in .htaccess as follows:
RewriteRule ^product/(.*)-([0-9]*)$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [B,L]
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
How about adding merchant at the start of the url? This is based on the assumption that none of my feeds have multiple merchants.
This is workin, but the .htaccess part isnt working.
return $config_baseHREF."product/".tapestry_hyphenate($product["merchant"])."-".urlencode(tapestry_hyphenate($product["normalised_name"]))."-(".tapestry_hyphenate($product["id"]).")";
Hi Richard,
If you separate the merchant from the product name by "/" that makes things much easier, and with the brackets removed as per the previous example, so using a includes/tapestry.php replacement of:
return $config_baseHREF."product/".tapestry_hyphenate($product["merchant"])."/".urlencode(tapestry_hyphenate($product["normalised_name"]))."-".tapestry_hyphenate($product["id"]);
And then in .htaccess
RewriteRule ^product/(.*)/(.*)-([0-9]*)$ products.php?q=$2&rewrite=1&%{QUERY_STRING} [B,L]
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Thanks Mate, Seems to be working.
I just noticed that Page 2 of search results isnt working. .htaccess is below. Is it do to the removal of .html?
{code saved}
Hi Richard,
It looks like the first search rule is missing, where you have added the following for re-written general queries;
RewriteRule ^search/(.*)/(.*)$ search.php?q=$1&page=$2&rewrite=1&log=1&%{QUERY_STRING} [L]
Based on your other rules re-writing to search.php this should include the .html, but also the top level (page 1 rewrite) - have a go with;
RewriteRule ^search/(.*)/$ search.php?q=$1&rewrite=1&log=1&%{QUERY_STRING} [L]
RewriteRule ^search/(.*)/(.*).html$ search.php?q=$1&page=$2&rewrite=1&log=1&%{QUERY_STRING} [L]
Cheers,
David.
--
PriceTapestry.com
I think 1 of these changes has broken the sitemap.php
Have a look at {link saved} and you will see the xml is missing the siteid
Hi Richard,
Ah yes - any fields included in construction of the product HREF will need to be added to the SELECT field list in sitemap.php. In that file, look for the following code at line 55:
$sql = "SELECT normalised_name FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($_GET["filename"])."' LIMIT ".$start.",".$limit;
...and REPLACE with:
$sql = "SELECT id,merchant,normalised_name FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($_GET["filename"])."' LIMIT ".$start.",".$limit;
Cheers,
David.
--
PriceTapestry.com
Hello Richard,
Ideally there needs to be a delimiter, or some method of absolutely differentiating the product name and the colour in the URL. One option would be brackets for example;
http://example.com/product/adidas-Pants-(black)
To give this a go, first the `colour` field needs to be added to the search result set re-query in search.php, so where you have the following code at line 476:
$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
...REPLACE with:
$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating,colour FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
Next, edit includes/tapestry.php and look for the following code around line 66:
return $config_baseHREF."product/".urlencode(tapestry_hyphenate($product["normalised_name"]));
(above has .html removed as already modified)
...and REPLACE with:
return $config_baseHREF."product/".urlencode(tapestry_hyphenate($product["normalised_name"]))."-(".tapestry_hyphenate($product["colour"]).")";
And then as the RewriteRule in .htaccess:
RewriteRule ^product/(.*)-\((.*)\)$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [B,L]
Hope this helps!
Cheers,
David.
--
PriceTapestry.com