You are here:  » Show ALL prices for mapped products in price tables

Support Forum



Show ALL prices for mapped products in price tables

Submitted by npaitken on Thu, 2010-04-01 08:48 in

Hi David,

I'd like to be able to display ALL prices for a mapped product in my price tables even where a merchant has >1 product under that mapping.

So, for example, at the minute I may have a mapped product but one of the merchants has a blue, yellow and a green version. I usually like to map all of the these together. With my current setup, the price table results will only show 1 product per merchant, say the blue one. I'd like to be able to display the blue, yellow and green one.

Is there a quick code change to show ALL prices for a merchant in price tables, where products have been mapped?

Thanks,
Neil

Submitted by support on Thu, 2010-04-01 11:13

Hi Neil,

Unfortunately it's not that simple i'm afraid as the mappings are applied at import time; so after the import, the blue/yellow/green versions etc. don't exist in the database.

One option that I think should work would be to add a new field to your `products` table called "originalname" of type VARCHAR(255). Then, make a copy of the original name field into a temporary variable before the Product Mapping is applied. To do this (assuming you go with the field name "originalname"), look for the following comment in includes/admin.php around line 228:

/* apply product mappings */

...and REPLACE with:

$originalname = $record[$admin_importFeed["field_name"]];
/* apply product mappings */

Next, look for the following code around line 251:

$dupe_key .= $record[$admin_importFeed["field_name"]];

...and REPLACE with:

$dupe_key .= $originalname;

...and then make sure that the new field is added to the product insert SQL, so look for the following code at line 270:

                    dupe_hash='%s'

...and REPLACE with:

                    dupe_hash='%s',
                    originalname='".database_safe($originalname)."'

With all that in place; search results should not be affected as they are still grouped by name, but then on the product page, all versions of the product should be selected; so you can then go about changing the name that is displayed in the prices table - html/prices.php, which is line 12 in the distribution;

<td><?php print $product["name"]; ?></td>

with:

<td><?php print $product["originalname"]; ?></td>

If you're not sure about adding the new field to the products table, the following dbmod.php script will do the job:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            ADD `originalname` VARCHAR(255) NOT NULL"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Upload to the main Price Tapestry folder, browse to it once, and then delete the file. You will have to re-import all feeds before the new field is populated...

Hope this helps!

Cheers,
David.

Submitted by npaitken on Thu, 2010-04-01 15:10

Brilliant David :-)

Worked perfectly first time.

Just browsing through some product pages and it looks like the results are being capped at a max of 10 results. Is this just coincidence or is this perhaps being controlled somewhere in the code?

Ideally, I don't want to cap the results at all.

Many thanks David.

Submitted by support on Thu, 2010-04-01 15:14

Hi Neil,

That's a legacy LIMIT clause that shouldn't be there in products.php you probably have at line 12:

    $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."' ORDER BY price LIMIT ".$config_resultsPerPage;

...REPLACE that with:

    $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."' ORDER BY price";

Cheers,
David.

Submitted by npaitken on Thu, 2010-04-01 15:35

Yes that's fixed it.

Thanks again David.

Submitted by npaitken on Fri, 2010-04-02 09:13

Hi David,

Just noticed that the same restriction seems to happening when I use pricesExternal.php. Do I need to make a similar code change somewhere?

Thanks,
Neil

Submitted by support on Sat, 2010-04-03 10:18

Hi Neil,

Exactly the same - in pricesExternal.php line 54, replace:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."' ORDER BY price LIMIT ".$config_resultsPerPage;

with:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."' ORDER BY price";

Cheers,
David.

Submitted by cfoss on Fri, 2011-07-29 04:30

Hi David - could you tell me what changes to the code I'd need to make for version 12/10B, if I want to make this modification? It doesn't appear that I have the code noted above in lines 251 and 270.

Thanks again for your help!!

Submitted by support on Fri, 2011-07-29 09:28

Hi cfoss,

12/10B already preserves (and uses on the price comparison table) an original_name field, so all you need to do is switch over dupe hash creation to original_name rather than normalised_name. To do this, look for the following code at line 354:

    $dupe_key .= $normalisedName;

...and REPLACE with:

    $dupe_key .= $importRecord["original_name"];

Cheers,
David.
--
PriceTapestry.com

Submitted by cfoss on Fri, 2011-07-29 18:25

Awesome - thanks David!

Submitted by cfoss on Sat, 2011-07-30 02:57

Hey David - it appears I am have the same problem as Neil with it the search maxing out at 10 products; however, my product.php line 12 code is different (due to the new version of PT). So what change do I need to make to fix this problem?

Thanks again!!

Submitted by support on Sat, 2011-07-30 07:05

Hi cfoss,

I've received your follow up and see that you've resolved this (co-incidence), I'll take a look at your capitilsation issue on the server now...

Cheers,
David.
--
PriceTapestry.com

Submitted by keshavkshirsagar on Tue, 2015-11-24 14:00

Hello David

Applying changes to dupe_key

$dupe_key = $importRecord["merchant"];
$dupe_key .= $importRecord["colour"]; //-------Custom Field---------
$dupe_key .= tapestry_mb_strtolower($searchName);

is it ok if we want to Dupe Hash field by unique merchant,colour & searchName

Or Required any other change in includes/admin.php

I am confuse for dupe_key with Custom field.

Submitted by support on Tue, 2015-11-24 14:21

Hi,

That will be fine but bear in mind, colour does not form part of the product naming, so you will potentially have the situation where a product page contains multiple results for the same merchant, which may well be exactly what you want to achieve - so no problem!

You can of course add the colour field to the price comparison table using the variable $product["colour"] within the loop...

Cheers,
David.
--
PriceTapestry.com

Submitted by keshavkshirsagar on Tue, 2015-11-24 16:47

Hello David,

Thanks for your quick reply.