You are here:  » Product Mapping with minimum price


Product Mapping with minimum price

Submitted by sirmanu on Mon, 2017-05-29 16:25 in

Hi David. I am using the excellent tool, Product Mapping. However, you probably know how difficult is sometimes map same items (even you check all alternatives).

Today, I have figured an idea that could lead to more accurate results. The idea is to add a new box into productsmap_configure.php with a minimum price for threshold.

For example, if you map for Iphone 7 128GB and you put 400€ for minimum price, you will discard a lot of cases, cables, accesorios, for instance.
Do you think is viable this idea? How could we implemented it?
Thank you for your time.

Submitted by support on Tue, 2017-05-30 10:41

Hi,

That would be straight forward to implement if you wanted to experiment with this approach - first create and run the following dbmod.php script to add a new `min_price` field to the `productsmap` table;

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."productsmap`
            ADD `min_price` DECIMAL(10,2) NOT NULL DEFAULT '0.00'
            "
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Edit admin/productsmap_configure.php and look for the following code at line 83:

              image_url = '".database_safe($_POST["image_url"])."',

...and REPLACE with:

              image_url = '".database_safe($_POST["image_url"])."',
              min_price = '".database_safe($_POST["min_price"])."'

And then the following code at line 115:

  widget_textBox("Custom Image URL","image_url",FALSE,$productmap["image_url"],"",6);

...and REPLACE with:

  widget_textBox("Custom Image URL","image_url",FALSE,$productmap["image_url"],"",6);
  widget_textBox("Minimum Price","min_price",FALSE,$productmap["min_price"],"",6);

Edit includes/admin.php and look for the following code at line 297:

    if (isset($admin_importProductMappingsOverrides[$importRecord["name"]]))

...and REPLACE with:

    global $admin_importProductMappingsMinPrice;
    if ($importRecord["original_name"] != $importRecord["name"])
    {
      if (tapestry_decimalise($importRecord["price"]) < $admin_importProductMappingsMinPrice[$importRecord["name"]])
      {
        $importRecord["name"] = $importRecord["original_name"];
      }
    }

And then the following code at line 555:

    global $admin_importProductMappings;

...and REPLACE with:

    global $admin_importProductMappings;
    global $admin_importProductMappingsMinPrice;

And finally the following code at line 630:

        $alternates = explode("\n",$productsmap["alternates"]);

...and REPLACE with:

        $alternates = explode("\n",$productsmap["alternates"]);
        $admin_importProductMappingsMinPrice[$productsmap["name"]] = $productsmap["min_price"];

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Wed, 2017-05-31 19:23

Excellent David. I am going to test it in next import!
I will post any problem (I hope not).
Thank you for your time.