You are here:  » Product Map Forwarder


Product Map Forwarder

Submitted by philstone on Wed, 2009-09-23 14:47 in

Hi David

Was wondering if this is possible

is there anyway that all products that are being filtered through the product map could automatically forward links to the new product name item

eg.

google organic sends web user to
{link saved}

but due to product mapping the product page no longer exists and in the product mapping page the new product name should see the user compare product prices at

{link saved}

is this possible?

thanks for your time

phil

Submitted by support on Wed, 2009-09-23 16:03

Hi Phil,

Should be straight forward by checking the product mapping table as part of the "not found" handling. In products.php, look for the following code around about line 58:

      $banner["h2"] .= "(".translate("product not found").")";

...and REPLACE this with:

      $sql = "SELECT * FROM `".$config_databaseTablePrefix."productsmap` WHERE alternates LIKE '%".database_safe($q)."%' LIMIT 1";
      if (database_querySelect($sql,$rows))
      {
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: /".tapestry_hyphenate($rows[0]["name"]).".html");
        exit();
      }
      $banner["h2"] .= "(".translate("product not found").")";

Cheers,
David.

Submitted by philstone on Mon, 2011-07-18 12:15

Hi David

Just wondering can this be changed to work for exact matches also?

regards

Phil Stone
www.buy24-7.net

Submitted by support on Mon, 2011-07-18 12:22

Hi Paul,

It's using LIKE with wildcards (%) before and after so it should work for exact matches as it stands above...

Cheers,
David.
--
PriceTapestry.com

Submitted by philstone on Thu, 2015-02-05 21:11

Hi David, trying to get this working in the new script to auto redirect where a product name has been removed to become part of a product mapping

eg so unmapped.html redirects to mapped.html

for some reason i just get a blank screen, and also the /product/ seems to be removed?

regards

Phil Stone
www.buy24-7.net

Submitted by support on Fri, 2015-02-06 09:42

Hello Phil,

Have a go with the following as the replacement which will select the full new product record and use the tapestry_productHREF() function to get the new URL...

      $sql = "SELECT * FROM `".$config_databaseTablePrefix."productsmap` WHERE alternates LIKE '%".database_safe($q)."%' LIMIT 1";
      if (database_querySelect($sql,$rows))
      {
        $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($rows[0]["name"])."' LIMIT 1";
        if (database_querySelect($sql,$rows))
        {
          header("HTTP/1.1 301 Moved Permanently");
          header("Location: ".tapestry_productHREF($rows[0]));
          exit();
        }
      }
      $banner["h2"] .= "(".translate("product not found").")";

Cheers,
David.
--
PriceTapestry.com

Submitted by philstone on Fri, 2015-02-06 09:52

Perfect David

Thanks!

regards

Phil Stone
www.buy24-7.net