You are here:  » Changing Product URL's


Changing Product URL's

Submitted by ChrisNBC on Thu, 2014-08-07 14:08 in

Hi David,

Hope all is well.

Wondered if you may be able to help me resolve an issue I have with a site using ASIN/EAN mappings. I have a number of links within the index page which I have directly linked to product pages. I did this by searching for a product and then copy and pasting the product URL into the page. For the last few days I have noticed then when I select some of these mapped links that they return a product no longer available message but then in the 'Related Results' section the product is displayed. Please could you suggest the best way to ensure the link stays valid.

Thanks in advance.

Regards
Chris

Submitted by support on Mon, 2014-08-11 11:07

Hi Chris,

The uidmap process selects with an ORDER BY name to try and persist the product name used when it is executed, but what I suspect is happening is that a new merchant comes along with a product name for that uid that is alphabetically before the currently selected name, and therefore that becomes the name for the product.

A quick solution would be a redirection script so that you can create a product link by UID regardless of the actual product name. To try this, create a new top level script uid2product.php containing the following code:

<?php
  
require("includes/common.php");
  
$uid = (isset($_GET["uid"])?$_GET["uid"]:"");
  
$sql "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE ".$config_uidField." = '".database_safe($uid)."' LIMIT 1";
  if (
database_querySelect($sql,$rows))
  {
    
header("Location: ".tapestry_productHREF($rows[0]));
  }
  else
  {
    
header("HTTP/1.0 404 Not Found");
  }
  exit();
?>

And then link to your products by uid, e.g.

<a href='/uid2product.php?uid=1234567890'>Product Name</a>

If you'd like to have a look at ways of creating more perstance of product names once one has been chosen, or alternatively using Product Mapping to specify an exact name by UID with priority over the uidmap process) let me know...

Cheers,
David.
--
PriceTapestry.com