You are here:  » Product update instead of deleting


Product update instead of deleting

Submitted by wdekreij on Wed, 2010-02-10 18:21 in

Is it also possible to update all products instead of deleting them? Thus, if product A is in the database but is not in the new datafeed, this product should stay untouched in the DB instead of deleting it.

Regards, Wilco

Submitted by support on Wed, 2010-02-10 19:22

Hi Wilco,

To do this (original distribution of Price Tapestry); look for the following 2 lines at around line 419 of includes/admin.php

    $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($admin_importFeed["merchant"])."'";
    database_queryModify($sql,$insertId);

...and either delete or comment out those lines.

That will prevent existing products from being deleted prior to import; but in addition, new products must be updated; so to do this; slightly higher up the script, look for the following comment at around line 258:

    /* create product record */

...and immediately BEFORE that point, add the following new code:

    $sql = sprintf("DELETE FROM `".$config_databaseTablePrefix."products` WHERE
                    merchant='%s',
                    AND
                    name='%s'
                    ",
                    database_safe($admin_importFeed["merchant"]),
                    database_safe($record[$admin_importFeed["field_name"]])
                    );
    database_queryModify($sql,$result);

In addition to the above; if you use import.php @ALL, then look for the following code in scripts/import.php starting at line 55:

    $sql = "TRUNCATE `".$config_databaseTablePrefix."products`";
    database_queryModify($sql,$result);

...and again either comment out or delete.

That should do the trick, but there will be a slight performance implication by doing individual rather than wildcard DELETEs, but should work fine...

Cheers,
David.

Submitted by Media Voogel on Mon, 2010-02-15 16:57

Hi David,

This solution would still remove the product and insert it as if it would be a new one? Is there a possibility to use something like ON DUPLICATE KEY UPDATE? Because now all the product id's change after a new import or an update....

Thanks,
Jelmer

Submitted by support on Mon, 2010-02-15 17:08

Hi Jelmer,

A little more code can certainly preserve the original record (and therefore ID), but as a suggestion what about using the name field (which is indexed) instead of ID - would that be a possibility in your application? `name` is used as a FK throughout Price Tapestry and shouldn't cause any significant performance issues (although it would not be as quick as an ID based FK)...

Cheers,
David.

Submitted by Media Voogel on Mon, 2010-02-15 17:19

Thanks for the quick reply David!

But I need an unique key on a product by product basis, would the dupe_hash be an option?

(Int uses less DB space as varchar, thats why I rather like to use the id value)

Thanks,
Jelmer

Submitted by support on Mon, 2010-02-15 17:24

Hi Jelmar,

I thought about dupe_hash the moment after I posted - yes that would be a much smaller index tree. It's not used as a FK throughout the script as the associations are `name` rather than `name+merchant` but if you need to refer to a specific record even after import it would be ideal.

Cheers,
David.

Submitted by don_load on Thu, 2010-02-18 22:58

This is actually something I've been looking at aswell. What I want to be able to do is have an extra productID field (int) thats unique for each product and is retained. I can then link in any extra info not present in the feed.

Is there a way of doing this by updating matching records rather than deleting them all. Then maybe records not matched are either deleted from the database or added; kinda like data syncing?

regards,
Jay

Submitted by support on Tue, 2010-02-23 14:53

Hello Jay,

There's a few steps involved with this; firstly a method to flag which product records need to be deleted as the DELETE process needs to be moved from before the import to afterwards. To do this, add a "deleteme" field to the `products` table, of type INT(11). You can either do this with your mySQL administration tool; or with the following dbmod.php script - (run once from the Price Tapestry installation folder):

dbmod.php

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

With that in place; the next step is to replace the initial DELETE with an UPDATE query to set deleteme to 1 for all products for the feed being imported. In includes/admin.php, look for the following code on line 441 (11/09A), 507 (12/10B) :

    $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";

...and REPLACE with:

    $sql = "UPDATE `".$config_databaseTablePrefix."products` SET deleteme='1' WHERE filename='".database_safe($admin_importFeed["filename"])."'";

Just a few lines later, after the import; look for the following code beginning at line 449 (11/09A), 515 (12/10B) :

    $sql = "SELECT COUNT(*) AS productCount FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";
    database_querySelect($sql,$rows);

...and REPLACE with:

    $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE deleteme='1'";
    database_queryModify($sql,$insertId);
    $sql = "SELECT COUNT(*) AS productCount FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";
    database_querySelect($sql,$rows);

Finally, look for the following code higher up the script within the import record handler function, at line 331 (11/09A), 386 (12/10B) :

    if (database_queryModify($sql,$insertId))
    {
      $admin_importProductCount++;
    }

...and REPLACE this with:

    $sql .= ",deleteme='0'";
    $sql2 = "SELECT id FROM `".$config_databaseTablePrefix."products`
               WHERE name='".database_safe($importRecord["name"])."' AND merchant='".database_safe($importRecord["merchant"])."'
               LIMIT 1";
    if (database_querySelect($sql2,$result))
    {
      $search = "INSERT INTO `".$config_databaseTablePrefix."products`";
      $replace = "UPDATE `".$config_databaseTablePrefix."products`";
      $sql = str_replace($search,$replace,$sql);
      $sql .= " WHERE name='".database_safe($importRecord["name"])."' AND merchant='".database_safe($importRecord["merchant"])."'";
    }
    if (database_queryModify($sql,$insertId))
    {
      $admin_importProductCount++;
    }

Hope this helps!

Cheers,
David.

Submitted by don_load on Tue, 2010-02-23 15:21

excellent, thanks david.

Submitted by don_load on Wed, 2010-02-24 11:42

Hi David, just going to make a start on this mod. Read a similar thread regarding timestamping updated rows, which could come in handy for myself as well. Having read both mods I'm thinking the alterations I need to perform are firstly to add the timestamp field and then replace the last block of code in the mod to this instead...

    global $now;
    if (!$now)
    {
      $now = time();
    }
    $sql .= ",deleteme='0'";
    $sql2 = "SELECT id FROM `".$config_databaseTablePrefix."products`
               WHERE name='".database_safe($importRecord["name"])."' AND merchant='".database_safe($importRecord["merchant"])."'
               LIMIT 1";
    if (database_querySelect($sql,$result))
    {
      $search = "INSERT INTO `".$config_databaseTablePrefix."products`";
      $replace = "UPDATE `".$config_databaseTablePrefix."products`";
      $sql = str_replace($search,$replace,$sql);
      $sql .= " WHERE name='".database_safe($importRecord["name"])."' AND merchant='".database_safe($importRecord["merchant"])."'";
    }
    else
    {
      $sql .= ",timestamp='".$now."'";
    }
    if (database_queryModify($sql,$insertId))
    {
      $admin_importProductCount++;
    }

Then I can just 'ORDER BY timestamp' and 'LIMIT' to list the latest dozen products or so. The other mod is related to the original PT though so wanted to check to see if I'm missing something?

regards,
Jay

Submitted by support on Wed, 2010-02-24 12:11

Hi Jay,

Looks fine to me...!

Cheers,
David.

Submitted by don_load on Wed, 2010-02-24 20:16

After applying this mod I've come across a strange problem. When I try to import a new feed it only imports 1 product out of 76 and a partial import only imports 46. If I do a full import from the admin home page after a partial import it reduces the products to just 1. Any ideas?

regards,
Jay

Submitted by support on Thu, 2010-02-25 10:42

Hi Jay,

Could you email me your modified includes/admin.php, i'll merge the changes into my test server and check it all out for you...

Cheers,
David.

Submitted by Gershi on Fri, 2011-02-25 12:43

Hi David

I would like to use product update instead of deleting, is it an option to make an additional parameter to chose between those 2 options?

Regards,
Gershi

Submitted by support on Fri, 2011-02-25 13:38

Hi Gershi,

Sure it can be made conditional - every place at which the modification to update rather than insert takes place has the `feed` record in scope. I notice that you're a new customer, so I will make the changes for you against the distribution version of includes/admin.php but if you have made changes to that file in the last couple of days email me your modified version and I'll merge the changes with that...

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Mon, 2011-03-07 20:03

hmm would the $sql2 not replace products that match from different merchants? For example if i had a product with the same name from different merchants would i not be updating any random one and not the one from that particular merchant?

Maybe i'm misinterpreting the code?

Would this not make sure that the products with the same name from different merchants are not overwritten?:

    $sql .= ",deleteme='0'";
    $sql2 = "SELECT id FROM `".$config_databaseTablePrefix."products`
               WHERE merchant='".database_safe($importRecord["merchant "])."'
               AND name='".database_safe($importRecord["name"])."'
               LIMIT 1";
    if (database_querySelect($sql2,$result))
    {
      $search = "INSERT INTO `".$config_databaseTablePrefix."products`";
      $replace = "UPDATE `".$config_databaseTablePrefix."products`";
      $sql = str_replace($search,$replace,$sql);
      $sql .= " WHERE merchant='".database_safe($importRecord["merchant "])."'
               AND name='".database_safe($importRecord["name"])."'";
    }
    if (database_queryModify($sql,$insertId))
    {
      $admin_importProductCount++;
    }

Cheers
Steve

Submitted by support on Mon, 2011-03-07 20:11

Hi Steve,

That's spot on - I noticed the same scenario with the mod recently - will update above also...

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Mon, 2011-03-07 20:12

Ah great :)

Was wondering if perhaps it was an overlook on my part rather than yours. I can carry on now then, without breaking too much :)

Cheers
Steve

Submitted by support on Mon, 2011-03-07 20:15

Just noticed a superfluous SPACE in your post -

$importRecord["merchant "]

...should be

$importRecord["merchant"]

(2 instances)

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Mon, 2011-03-07 20:25

Thanks for that,

Didn't seem to affect the mod, but still nice to correct it early on.

Am right in thinking that this mod merely replaces the information in the database? So if i went about editing the description, it would in fact be replaced on the next import?

So ideally to create an extra description i would have to modify the product table and add an additional field in which that information would be pulled from? So it wouldn't be replaced?

Submitted by support on Tue, 2011-03-08 08:49

Hi Steve,

The objective of the mod is to preserve the ID value for a merchant+product combo where either additional tables have been created that have the product ID as a foreign key; or a `clicks` columns for example has been added to the products table for individual product tracking.

It does mean as you correctly observe that all other fields are replaced at each import so any edits to the description would be lost, just as normal. An alternative to modifying the database for custom descriptions that several users have implemented is described in this thread which may be of interest...!

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Wed, 2011-03-09 18:16

hmm just so i'm clear, even creating a new in products table will result in that field being cleared, is it possible to stop this happening.

My plan is to map the current categories provided by the merchants into a sub cat field, and then using my own categories from a different table and map those sub categories to it.

Basically i want to be able to store the main categories foreign key in the product database without it being overwritten by the merchant data.

Obviously i don't want to put extra strain on the server, so i'm looking for the most feasible option.

Would a separate table with the foreign keys from both tables stored be the best option? I'd like to create more than one sub category if possible, so that option would be handy.

Of course i'm just fishing for idea's and don't expect you to code anything, just your opinion would be great.

Thanks
Steve

Submitted by support on Wed, 2011-03-09 18:32

Hi Steve,

Whilst the mod does overwrite the normal fields (e.g. anything in $config_fieldSet - see config.advanced.php, any additional fields that you have added to the products table that are managed outside of the usual register / import mechanism will be preserved - so you should actually be ok...!

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Wed, 2011-03-09 18:48

Oh i'll have to look into that, thanks.

Any thoughts on the best way to proceed on this category idea?

I'm splitting the category like so:

$category = "console > wii > games";
list($maincat, $subcat1, $subcat2) = explode(">", $category);
echo $maincat;
echo "<br />";
echo $subcat1
echo "<br />";
echo $subcat2;

hmm i having trouble getting my head around this a little :( Not sure the best route too take. Would placing each variable into a seperate field in the table, and then also have the foreign key for the main categories be practical?

Submitted by support on Thu, 2011-03-10 08:52

Hi Steve,

You may find the explode() function easier to use. The following will pickout the top and lowest level into $maincat and $subcat....

$category = "console > wii > games";
$parts = explode(" > ",$category);
$maincat = $parts[0];
$c = count($parts);
if ($c > 1)
{
  $subcat = $parts[($c-1)];
}
echo $maincat;
echo "<br />";
echo $subcat;

Alternatively, to make $subcat be the second level (which may be more appropriate), in place of:

  $subcat = $parts[($c-1)];

...use:

  $subcat = $parts[1];

Within the import record handler, you could of course start with

$category = $importRecord["category"];

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Thu, 2011-03-10 19:54

Ah thanks again david.

If i ever get anywhere with this, i'll post some updates as i know it's one those mods most people would love to have.

Steve

Submitted by Halion on Wed, 2013-11-13 16:03

Hi David,

A little way down this Thread 3273 you wrote:

" A little more code can certainly preserve the original record (and therefore ID). "

I would like to preserve the id number of existing products in the database upon import. Could you supply that code please? Also would I have to implement the code changes above from that comment you made?

Thanks

Mike

Submitted by support on Wed, 2013-11-13 17:41

Hello Mike,

Here's the row preservation modifications updated for 13/03A.

Firstly a method to flag which product records need to be deleted as the DELETE process needs to be moved from before the import to afterwards. To do this, add a "deleteme" field to the `products` table, of type INT(11). You can either do this with your mySQL administration tool; or with the following dbmod.php script - (run once from the Price Tapestry installation folder):

dbmod.php

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

With that in place; the next step is to replace the initial DELETE with an UPDATE query to set deleteme to 1 for all products for the feed being imported. In includes/admin.php, look for the following code on line 535:

    $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";

...and REPLACE with:

    $sql = "UPDATE `".$config_databaseTablePrefix."products` SET deleteme='1' WHERE filename='".database_safe($admin_importFeed["filename"])."'";

Just a few lines later, after the import; look for the following code beginning at line 449:

    $sql = "SELECT COUNT(*) AS productCount FROM `".$config_databaseTablePrefix.$table."` WHERE filename='".database_safe($admin_importFeed["filename"])."'";
    database_querySelect($sql,$rows);

...and REPLACE with:

    $sql = "DELETE FROM `".$config_databaseTablePrefix.$table."` WHERE deleteme='1'";
    database_queryModify($sql,$insertId);
    $sql = "SELECT COUNT(*) AS productCount FROM `".$config_databaseTablePrefix.$table."` WHERE filename='".database_safe($admin_importFeed["filename"])."'";
    database_querySelect($sql,$rows);

Finally, look for the following code higher up the script within the import record handler function, at line 396:

    if (database_queryModify($sql,$insertId))
    {
      $admin_importProductCount++;
    }

...and REPLACE this with:

    $sql .= ",deleteme='0'";
    $sql2 = "SELECT id FROM `".$config_databaseTablePrefix."products`
               WHERE name='".database_safe($importRecord["name"])."' AND merchant='".database_safe($importRecord["merchant"])."'
               LIMIT 1";
    if (database_querySelect($sql2,$result))
    {
      $search = "INSERT INTO `".$config_databaseTablePrefix."products`";
      $replace = "UPDATE `".$config_databaseTablePrefix."products`";
      $sql = str_replace($search,$replace,$sql);
      $sql .= " WHERE name='".database_safe($importRecord["name"])."' AND merchant='".database_safe($importRecord["merchant"])."'";
    }
    if (database_queryModify($sql,$insertId))
    {
      $admin_importProductCount++;
    }

Preserving row IDs isn't compatible with the zero down-time mod (which isn't an issue when updating rather than deleting / inserting anyway) so this needs to be disabled in scripts/cron.php. Look for the following code beginning at line 71:

  $admin_importAll = TRUE;
  $sql = "DROP TABLE IF EXISTS `".$config_databaseTablePrefix."products_import`";
  database_queryModify($sql,$result);
  $sql = "CREATE TABLE `".$config_databaseTablePrefix."products_import` LIKE `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);
  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products_import` DISABLE KEYS";
  database_queryModify($sql,$result);

...and REPLACE with:

  $admin_importAll = FALSE;
  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products` DISABLE KEYS";
  database_queryModify($sql,$result);

...and the following code at line 108:

  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products_import` ENABLE KEYS";
  database_queryModify($sql,$result);
  $sql = "DROP TABLE `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);
  $sql = "RENAME TABLE `".$config_databaseTablePrefix."products_import` TO `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);

...REPLACE with:

  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products` ENABLE KEYS";
  database_queryModify($sql,$result);

Similarly in scripts/import.php, look for the following code beginning at line 54:

  $admin_importAll = TRUE;
  $sql = "DROP TABLE IF EXISTS `".$config_databaseTablePrefix."products_import`";
  database_queryModify($sql,$result);
  $sql = "CREATE TABLE `".$config_databaseTablePrefix."products_import` LIKE `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);
  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products_import` DISABLE KEYS";
  database_queryModify($sql,$result);

...and REPLACE with:

  $admin_importAll = FALSE;
  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products` DISABLE KEYS";
  database_queryModify($sql,$result);

...and the following code at line 80:

  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products_import` ENABLE KEYS";
  database_queryModify($sql,$result);
  $sql = "DROP TABLE `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);
  $sql = "RENAME TABLE `".$config_databaseTablePrefix."products_import` TO `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);

...REPLACE with:

  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products` ENABLE KEYS";
  database_queryModify($sql,$result);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Wed, 2013-11-13 21:11

Hi David and thanks for your reply.

I am still using 12/10B and not 13/03A as modifications have been made. Could I possibly ask you how I would do it for 12/10B?

Thanks

Mike

Submitted by support on Wed, 2013-11-13 21:33

Hello Mike,

Code changes are identical to the original version described for 11/09A above in this comment, which I've just updated giving line numbers for both 11/09A and 12/10B...

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Wed, 2013-11-13 23:11

Hi David,

I have done the changes as suggested, but the ID number for a given product is still changing, as displayed on /jump.php?id=xxxxx, (the click through link using tracking=true in config.php)when I reimport the same feed. What I would like is that the jump.php id number remains the same if it's the same product upon import.

Thanks

Mike

Submitted by support on Thu, 2013-11-14 11:07

Hello Mike,

My apologies - 12/10B uses a TRUNCATE operation in scripts/import.php (when using @ALL) and scripts/cron.php.

In scripts/import.php, look for the following code beginning at line 56:

    $sql = "TRUNCATE `".$config_databaseTablePrefix."products`";
    database_queryModify($sql,$result);

...and either comment out or delete those lines.

Similarly, in scripts/cron.php, look for the following code beginning at line 77:

  $sql = "TRUNCATE `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);

...and again either comment or delete, and that should be all it is...

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Thu, 2013-11-14 11:57

Hi David, have tried the extra changes you suggest but id number is still changing. I use slow import and am testing by slow importing one of the two csv feeds in the installation. Would that affect the instructions you have given?

Thanks
Mike

Submitted by support on Thu, 2013-11-14 12:03

Hello Mike,

In 12/10B, the slow import process actually implements deletion and product counting itself so equivalent changes have to be made there. In admin/feeds_import_slow.php, look for the following code at line 48:

    $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";

...and REPLACE with:

    $sql = "UPDATE `".$config_databaseTablePrefix."products` SET deleteme='1' WHERE filename='".database_safe($admin_importFeed["filename"])."'";

And then look for the following code at line 157:

    $sql = "SELECT COUNT(*) AS productCount FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";

...and REPLACE with:

    $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE deleteme='1'";
    database_queryModify($sql,$insertId);
    $sql = "SELECT COUNT(*) AS productCount FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Thu, 2013-11-14 12:40

Hi David,

Thanks for your great help, have tested and appears to be ok. My test product detail page retains the id number upon slow re-import.

Just one final point, I also implemented the code changes from your very first reply (to Wilco) at the top of this thread. Is that coding only necessary to retain products that no longer appear in the feed, and is not necessary for preserving existing product id only? I've done it anyway, but would like to know.

Thanks again

Mike

Submitted by support on Thu, 2013-11-14 12:44

Hello Mike,

The code in the first reply isn't associated to the preservation of IDs, that's for the preservation of deleted products once they've gone from the feeds...

However, bear in mind that code would actually interfere with the preservation of IDs mod from 12/10B onwards where a merchant name was specified on Feed Registration Step 2 rather than selected as a field in the feed, so it's probably best to delete that code in case it causes unexpected problems in the future.

For completeness, the equivalent modification to keep products that no longer exist in feeds would be to simply skip the DELETE FROM ... WHERE deleteme='1' query which would have the same effect.

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Thu, 2013-12-05 13:39

Works fine when I manually fetch and import slow, but when I use cron to do it automatically the ID numbers are still changing for existing products. Is there also a change I need to make to any of the cron scripts?

Thanks
Mike

Submitted by support on Thu, 2013-12-05 15:40

Hello Mike,

That sounds like the equivalent changes may not have been applied in scripts/cron.php. In that file, look for the following code beginning at line 71:

  $admin_importAll = TRUE;
  $sql = "DROP TABLE IF EXISTS `".$config_databaseTablePrefix."products_import`";
  database_queryModify($sql,$result);
  $sql = "CREATE TABLE `".$config_databaseTablePrefix."products_import` LIKE `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);
  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products_import` DISABLE KEYS";
  database_queryModify($sql,$result);

...and REPLACE with:

  $admin_importAll = FALSE;
  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products` DISABLE KEYS";
  database_queryModify($sql,$result);

...and the following code at line 108:

  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products_import` ENABLE KEYS";
  database_queryModify($sql,$result);
  $sql = "DROP TABLE `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);
  $sql = "RENAME TABLE `".$config_databaseTablePrefix."products_import` TO `".$config_databaseTablePrefix."products`";
  database_queryModify($sql,$result);

...REPLACE with:

  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products` ENABLE KEYS";
  database_queryModify($sql,$result);

If that all looks in place let me know and I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Thu, 2013-12-05 16:22

Hi David,

I'm using version 12/10B, I think the code you have given is for 13/03. Could you advise cron code changes for 12/10B?

I have already deleted

$sql = "TRUNCATE `".$config_databaseTablePrefix."products`";
database_queryModify($sql,$result);

in scripts/cron.php as recommended higher up the thread.

Import slow manually is preserving the ID's, cron is not, so I guess there must be something in either import or cron.php.

Thanks
Mike

Submitted by support on Thu, 2013-12-05 16:37

Hi Mike,

Can you check that exactly the same code has been deleted from lines 56-58 in scripts/import.php (it's possible your CRON process is calling import.php @ALL rather than cron.php) - that should be all it is...

    $sql = "TRUNCATE `".$config_databaseTablePrefix."products`";
    database_queryModify($sql,$result);

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Thu, 2013-12-05 19:16

Hi David,

Have already done those deletes in scripts/import.php and scripts/cron.php. By cron ID numbers are still changing.

The cron process is calling :

scripts/import_slow.php?password=XXX&filename=@ALL" > /dev/null 2>&1

I have deleted

$sql = "TRUNCATE `".$config_databaseTablePrefix."products`";
database_queryModify($sql,$result);

from scripts/import.php and scripts/cron.php - it's not in scripts/import_slow.php. Could that have anything to do with it?

Thanks
Mike

Submitted by support on Thu, 2013-12-05 19:53

Hi Mike,

Apologies for the confusion - please could you email me your latest versions of

includes/admin.php
scripts/import_slow.php

...and I'll check it all out for you...

Thanks!
David.
--
PriceTapestry.com

Submitted by Halion on Thu, 2013-12-05 20:30

Hi David

Thanks, have emailed you the 2 files.

Mike