You are here:  » INSERT AND Update Only Price & Buy URL on Feed Slow Import


INSERT AND Update Only Price & Buy URL on Feed Slow Import

Submitted by keshavkshirsagar on Sat, 2017-03-25 09:59 in

Hello David,

How we can update only Only Price & Buy URL on Feed Slow Import if change
Do not want to delete feed records just want to update price and Buy URL or Image URL
Because we are keeping product views and other info

Submitted by support on Sat, 2017-03-25 13:01

Hi,

I'm assuming you have already implemented the UPDATE / INSERT modifications described in this thread. To extend the modification to the Slow Import Tool, edit admin/feeds_import_slow.php and look for the following code at line 20:

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

...and REPLACE with:

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

And then the following code at line 44:

    $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_querySelect($sql,$rows);
    $sql = "SELECT COUNT(*) AS productCount FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($admin_importFeed["filename"])."'";

And finally the following code beginning at line 108:

  if ($offset=="0|0")
  {
    import_slow_pre();
    $sql = "SELECT COUNT(*) AS numProducts FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($admin_importFeed["filename"])."'";
    database_querySelect($sql,$rows);
    if ($rows[0]["numProducts"])
    {
      $refresh = $refreshBase."feeds_import_slow.php?filename=".$filename."&progress=0&offset=0|0&starttime=".$starttime;
      $deleting = $rows[0]["numProducts"];
    }
  }

...and REPLACE with:

  if ($offset=="0|0")
  {
    import_slow_pre();
  }

As always with modifications to the import process make sure that you have a good backup of the database including products table so that you can revert easily if necessary...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco on Fri, 2018-01-26 14:58

Hello,

Is this still valid for 16/10A?
I have implemented this mod (in combination with 5513).
But if I slow import a feed the products from the other feeds are deleted from the products table.

Best,
Marco

Submitted by support on Fri, 2018-01-26 15:12

Hello Marco,

There was an error in the first REPLACEment above (line 20) -

    $sql = "UPDATE `".$config_databaseTablePrefix."products` SET deleteme='1'";

...should be:

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

(corrected above)

Cheers,
David.
--
PriceTapestry.com

Submitted by marco on Fri, 2018-01-26 15:51

Thanks!

Submitted by Baptiste on Sat, 2019-02-16 21:57

Hello David,

Nice to meet you! :)

I made the changes but i would like to update only the URL and the price. There, all the fields are modified.

It's possible ?

Thanks.

Submitted by support on Sun, 2019-02-17 12:21

Hello Baptiste and welcome to the forum!

Sure - to update only URL and price, as an alternative to the replacement to includes/admin.php (line 523 as per node/5513) use:

    $sql2 = "SELECT id FROM `".$config_databaseTablePrefix."products`
               WHERE dupe_hash='".$dupe_hash."'
               LIMIT 1";
    if (database_querySelect($sql2,$result))
    {
      $sql = "UPDATE `".$config_databaseTablePrefix."products`
               SET
               buy_url='".database_safe($importRecord["price"])."',price='".database_safe($importRecord["price"])."',deleteme='0'
               WHERE
               dupe_hash='".$dupe_hash."'";
    }
    if (database_queryModify($sql,$insertId))
    {
      $admin_importProductCount++;
    }

Cheers,
David.
--
PriceTapestry.com