You are here:  » cron.php with slow import function


cron.php with slow import function

Submitted by kgalkowski on Tue, 2014-08-26 13:02 in

Hi David,

is ist possible to modify the cron.php file with slow import function
and temporary products_import table logic. So that I can fetch the data, import slow the rows and finally rename after execution? All in one step?

Submitted by support on Tue, 2014-08-26 13:33

Hi there, and welcome to the forum!

That is the cron.php process as it stands, so I'm wondering if it was just a case of slowing the process down to reduce server load during import that you were looking to do, in which case simply adding the 1 second sleep every 100 products mod from this comment would do the trick nicely.

Furthermore, you could extend the mod so that it only applies when CRON (or a kind of initiated full import) is running by replacing this line:

  if (!($admin_importProductCount % 100))

...with:

  if (isset($admin_importAll) && !($admin_importProductCount % 100))

If that's not the reason, if you could let me know your current CRON set-up I do have a "scriptable" version of the slow import tool that requires wget (or at least some kind of HTTP) invocation and I'll point you in the right direction...

Cheers,
David.
--
PriceTapestry.com

Submitted by kgalkowski on Thu, 2014-08-28 14:20

Thanks...

I have set max_execution_time to 300 - no problems with import and 1 seconds sleep modification!

Is it possible to delete some old rows in temporary products_import Table before drop and rename the live table? I have a column "time_new" in my database.
My try was something like:

$sql = "DELETE FROM `".$config_databaseTablePrefix."products_import` WHERE DATEDIFF(NOW(),`time_new`) > 10";
database_queryModify($sql,$result);

before

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

in cron.php

... results in 500 Error

Submitted by support on Fri, 2014-08-29 07:51

Hi,

The products_import table is created empty at the start of the import all process ( CREATE TABLE ... LIKE ... ) so there won't actually be any old rows to delete as such - the best way to keep the database entirely up to date with the feeds is simply to delete and re-import which is the standard process - however let me know if you've implemented INSERT / UPDATE at all perhaps in combination with the import all process, as there is a straight forward technique using a `deleteme` flag for removing old products in this case...

Cheers,
David.
--
PriceTapestry.com