You are here:  » How To Allow Duplicate Product Names For Single Merchant

Active Forum Topics


How To Allow Duplicate Product Names For Single Merchant

Submitted by keshavkshirsagar on Fri, 2015-09-04 13:01 in

Hello Sir

How We Can Allow Duplicate Product Names

I have CSV's With Same Product Name though they have different (Diff Price according to Product Color,Product Images)

I would like to modify the code to check the duplication as a combination of product name and product id. I have read the forum, but could you help me with the code changes in the pages. Also we need the product name to remain unchanged as it would affect the mapping if the name is modified.

We are using pricetapestry 15/09A (Beta)

Submitted by support on Sat, 2015-09-05 09:30

Hi,

The easiest way to allow duplicate products per merchant is to drop the dupe_filter unique key which is the mechanism through which the duplicate prevention is implemented. To do this, simply run the following dbmod.php script in the top level folder of your Price Tapestry installation, delete the file, and then re-import all feeds to allow the duplicates in:

<?php
  set_time_limit
(0);
  require(
"includes/common.php");
  
$sql "TRUNCATE `".$config_databaseTablePrefix."products`";
  
database_queryModify($sql,$result);
  
$sql "DROP INDEX dupe_filter ON `".$config_databaseTablePrefix."products`";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

To re-instate duplicate prevention on an installation where the above script has been applied, use the following script:

<?php
  set_time_limit
(0);
  require(
"includes/common.php");
  
$sql "TRUNCATE `".$config_databaseTablePrefix."products`";
  
database_queryModify($sql,$result);
  
$sql "CREATE UNIQUE INDEX dupe_filter ON `".$config_databaseTablePrefix."products` (dupe_hash)";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Notice that both scripts TRUNCATE (empty) the products table first, so after running the scripts there will be no products on your site and a full import will be required (this won't affect your product mapping at all, that all stays in place in other tables...)

Cheers,
David.
--
PriceTapestry.com

Submitted by keshavkshirsagar on Sat, 2015-09-05 11:40

Thank David

One more question
If we will do duplicate entry.

Will affect Product Comparison & existing product Mapping
Or How will Work Product Comparison

Submitted by support on Sat, 2015-09-05 12:31

Hi,

Product Mapping will be applied to all instances of the same product name for the same merchant, so there will still only be 1 price comparison page for the product name, but it may contain multiple entries for the same merchant, that's all.

if you have added custom fields to your site and furthermore added columns for the custom fields to the price comparison table (html/prices.php) then this is where users would be able to differentiate between the different versions.

If the different versions of the same product are different prices, they will be in price order (lowest to highest) just as if they were from different merchants.

Cheers,
David.
--
PriceTapestry.com

Submitted by keshavkshirsagar on Mon, 2015-09-07 14:03

Thank you David!

Submitted by keshavkshirsagar on Wed, 2015-09-09 11:22

Hello David

I have shown product variations in product page of same compare merchant

How we I can hide numMerchants count of same Merchants ie 2 compare ,3 compare in category or in search result page

if product entry 3 times duplicate from same Merchant it should count only 1 compare or more info instead of showing 3 compare

Duplicate names of single merchant count should be 1

Submitted by support on Wed, 2015-09-09 11:55

Hi,

This would need to be done with a re-query as the search results SQL can only include one grouping however the necessary query can be executed entirely from indexes so will be very fast and should not impact page speed at all. To give it a go, edit search.php and look for the following code at line 493:

  $searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);

...and REPLACE with:

  $searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);
  $sql4 = "SELECT COUNT(DISTINCT(merchant)) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($searchresults["products"][$k]["name"])."'";
  database_querySelect($sql4,$rows4);
  $searchresults["products"][$k]["numMerchants"] = $rows4[0]["numMerchants"];

Cheers,
David.
--
PriceTapestry.com

Submitted by keshavkshirsagar on Wed, 2015-09-09 12:04

Its perfect Thanks :)

Submitted by keshavkshirsagar on Wed, 2015-09-09 13:20

Hello Sir

Should we required to remove bellow code

if ($parts[0]=="merchant")
{
  $sql4 = "SELECT COUNT(id) AS numMerchants
FROM `".$config_databaseTablePrefix."products`
WHERE name='".database_safe($searchresults["products"][$k]["name"])."'";
database_querySelect($sql4,$rows4);
$searchresults["products"][$k]["numMerchants"] = $rows4[0]["numMerchants"];
}

Because if we remove this code suggested new code for line 493 working

Submitted by support on Wed, 2015-09-09 13:24

Yes - remove that mod as the new code for line 493 will take over providing that functionality...

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Thu, 2017-04-06 14:38

Hi David,
I have a merchant with same product names (but different images) that I want to allow duplicate names. Can this be done per merchant only? Also using 15/09A.

Submitted by support on Fri, 2017-04-07 06:42

Hi,

You could add the image URL to the string from which the duplicate key value is generated for a specific merchant - to try this, edit includes/admin.php and look for the following code around line 481:

    $dupe_key = $importRecord["merchant"];

...and REPLACE with:

    $dupe_key = $importRecord["merchant"];
    $allowDupes = array("Merchant Name");
    if (in_array($importRecord["merchant"],$allowDupes))
    {
      $dupe_key .= $importRecord["image_url"];
    }

Using in_array makes it easy to apply the same code to more than one merchant, so if you want to apply the same to another merchant in the future, use for example;

    $allowDupes = array("Merchant 1","Merchant 2");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Ride on Fri, 2017-06-16 15:00

Is that mod still valid for 16/10A?
Thank you!

Submitted by support on Fri, 2017-06-16 15:06

Hello Ride and welcome to the forum!

Yes - the mod described is valid for 16/10A distribution / line-numbering...

Cheers,
David.
--
PriceTapestry.com

Submitted by Ride on Fri, 2017-06-16 15:13

Fastest support ever!
Thank you