You are here:  » voucher import deleting products


voucher import deleting products

Submitted by philstone on Tue, 2017-07-11 23:15 in

Hi David

I'm working on a new install currently but have hit a problem, when i import feeds with advanced voucher codes it deletes the products but imports all other products with no codes, please can you help with what code would be causing this to happen, so the voucher codes appear on the vouchers.php but when you click view products there are no items listed as they have been removed on import

Thanks

Phil

Submitted by support on Wed, 2017-07-12 07:43

Hello Phil,

If this is only affecting some vouchers it may be the case that other codes apply a better discount for all relevant products as the script only associates the code with the best discount with a particular product.

To check, if not already using level 2 voucher code integration (discount calculated at import time) then if you could enable this by editing config.advanced.php (line 41) as follows;

  $config_useVoucherCodes = 2;

Then run a full import to ensure the voucher code field is populated, and then edit vouchers.php and look for the following code at line 6:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."vouchers` WHERE ( (valid_from < '".$now."' AND valid_to = '0') OR (valid_from <= '".$now."' AND valid_to > '".$now."') ) ORDER BY merchant";

...and REPLACE with:

  if ($config_useVoucherCodes==2)
  {
    $sql = "SELECT *,CONCAT(merchant,code) AS merchant_voucher_code FROM `".$config_databaseTablePrefix."vouchers` HAVING merchant_voucher_code IN (SELECT CONCAT(merchant,voucher_code) AS merchant_voucher_code FROM `".$config_databaseTablePrefix."products` ) ORDER BY merchant";
  }
  else
  {
    $sql = "SELECT * FROM `".$config_databaseTablePrefix."vouchers` WHERE ( (valid_from < '".$now."' AND valid_to = '0') OR (valid_from <= '".$now."' AND valid_to > '".$now."') ) ORDER BY merchant";
  }

(i've made a note to address this in the next distribution)

Cheers,
David.
--
PriceTapestry.com