You are here:  » Lost related product


Lost related product

Submitted by henk on Mon, 2013-01-28 12:16 in

Hello David,

Somewhere i have lost my related products, where can i check this?

Thx
Henk

Submitted by support on Mon, 2013-01-28 12:20

Hi Henk,

From wp-admin > Settings > PriceTapestry.org scroll down to the Extenal section and make sure the plugin equivalent for $config_useRelated is set to TRUE - that should be all it is!

Cheers,
David.
--
PriceTapestry.com

Submitted by henk on Mon, 2013-01-28 14:23

Hi David,

No, it's set to true, maybe database indexes?

Henk

Submitted by support on Mon, 2013-01-28 15:03

Hello Henk,

Possible - first thing to do in case keys have become disabled on the table, create a script as follows, upload and run from the Price Tapestry installation folder (/pt/)

enablekeys.php

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products` ENABLE KEYS";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

If that has no effect, it could be that the FULL TEXT index on name has been dropped; but rather than overload your database with indexes it's best to make the related products query use the same full text index as normal queries, which I see from your latest pto_search.php is name,brand - so in pto_product.php look for the following code beginning at line 153:

  $where = "MATCH name AGAINST ('".$wpdb->escape($product->name)."') AND name <> '".$wpdb->escape($product->name)."'";
  if ($product->category)
  {
    $where .= " AND category = '".$wpdb->escape($product->category)."'";
  }
  $sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH name AGAINST ('".$wpdb->escape($product->name)."') AS relevance FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$where." GROUP BY name ORDER BY relevance DESC LIMIT 3";

...and REPLACE with:

  $where = "MATCH name,brand AGAINST ('".$wpdb->escape($product->name)."') AND name <> '".$wpdb->escape($product->name)."'";
  if ($product->category)
  {
    $where .= " AND category = '".$wpdb->escape($product->category)."'";
  }
  $sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH name,brand AGAINST ('".$wpdb->escape($product->name)."') AS relevance FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$where." GROUP BY name ORDER BY relevance DESC LIMIT 3";

Cheers,
David.
--
PriceTapestry.com

Submitted by henk on Mon, 2013-01-28 15:47

Pff, its working again, its also w3c Validated ( html5)

Thx
Henk