You are here:  » Products Where Retail Price is Equal to Sale Price


Products Where Retail Price is Equal to Sale Price

Submitted by ItsDavid on Tue, 2018-11-06 06:08 in

Hi David,

I have a dilemma where many of my product feeds have either,

1: Sale Price Equal to the Retail Price

OR

2: Sale Price Only

I currently have a modification that only imports the product if Sale Price is less then Retail Price, however, both records must have a value otherwise the product gets skipped without being imported into the database.

I am wondering if there is an easy way to modify PT so that in the cases where Sale Price is equal to Retail Price or only Sale Price exists I can have a new table "Retail Products" in the database where these products can be imported and all other products that have a Sale Price less then Retail Price would get imported into the "Products" table as normal?

My thoughts are that once the products are imported into the "Retail Products" table I could track down the retail prices for each product and somehow edit the prices then move it to the "Products" table and upon future imports, PT would leave the "Retail Prices" intact and untouched without deleting them.

Does this sound like a modification that could be done fairly easy? If this is not something that could be done fairly easy would you happen to have any ideas of the best way to deal with this?

Best Regards,
David

Submitted by support on Tue, 2018-11-06 08:40

Hi David,

Assuming that you are mapping sale price to "Price" and retail price is a custom field "rrp" (I think this is the case from previous mods described), then you could create a CSV file in the feeds directory "products_rrp_check.csv" containing product names, price and rrp fields for products that are not imported.

To do this, edit includes/admin.php and immediately before the code that checks whether to skip the product (by return'ing from the import record handler function), use something like this;

    if (!$importRecord["rrp"] || ($importRecord["price"]==$importRecord["rrp"]))
    {
      global $admin_products_fp;
      global $config_feedDirectory;
      if (!isset($admin_products_fp))
      {
        $admin_products_fp = fopen($config_feedDirectory."products_rrp_check.csv","w");
        fwrite($admin_products_fp,"product_name,price,rrp\n");
      }
      fwrite($admin_products_fp,$importRecord["name"].",".$importRecord["price"].",".$importRecord["rrp"]."\n");
    }

After import, you can then look at feeds/products_rrp_check.csv to see what products have been skipped because of no rrp or rrp equal to price. What you could then do is add the modification described in Additional custom fields in Product Mapping for the field "rrp" as a mechanism through which to set rrp for products where it is missing...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com