From 31d77b1d60648fb81aae730c8ff6b3fc9c883aba Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Wed, 23 Nov 2016 15:19:50 +0100 Subject: [PATCH] fix cron to send articles to philea --- modules/philea_magistor/cron.php | 57 ++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/modules/philea_magistor/cron.php b/modules/philea_magistor/cron.php index 69808e67..72b1d45c 100644 --- a/modules/philea_magistor/cron.php +++ b/modules/philea_magistor/cron.php @@ -5,31 +5,46 @@ include dirname(__FILE__).'/../../config/config.inc.php'; if(isset($_SERVER['REMOTE_ADDR'])) { exit; } +// CHECKING RUNNING OF CRON_SALE_CACHE +$fileName = 'cron_sale_cache.php'; +$output = shell_exec("ps -ax | grep $fileName | wc -l"); +if($output > 2){ + exit; +} + set_time_limit(600); if($row = Db::getInstance()->getRow(' - SELECT * - FROM `'._DB_PREFIX_.'philea_sync` - WHERE `status` = 0 - ORDER BY `date_add` ASC + SELECT * + FROM `'._DB_PREFIX_.'philea_sync` + WHERE `status` = 0 + ORDER BY `date_add` ASC ')) { - // SEND ART01 - Db::getInstance()->ExecuteS(' - UPDATE `'._DB_PREFIX_.'philea_sync` - SET `status` = 1 - WHERE `id_sync` = '.(int) $row['id_sync'].' - LIMIT 1 - '); - system('cd '.dirname(__FILE__).'/script && php send_article.php '.(int) $row['id_sale']); - sleep(20); + // CHECKING ASSOCIATED PRODUCTS + $associated_products = Db::getInstance()->getValue(' + SELECT COUNT(`id_sale`) + FROM `'._DB_PREFIX_.'product_ps_cache` + WHERE `id_sale` = '.(int) $row['id_sale'].' + '); + if($associated_products > 0) { + // SEND ART01 + Db::getInstance()->ExecuteS(' + UPDATE `'._DB_PREFIX_.'philea_sync` + SET `status` = 1 + WHERE `id_sync` = '.(int) $row['id_sync'].' + LIMIT 1 + '); + system('cd '.dirname(__FILE__).'/script && php send_article.php '.(int) $row['id_sale']); + sleep(20); - // SEND REC01 - pas de gestion recption fournisseur sur bbb - Db::getInstance()->ExecuteS(' - UPDATE `'._DB_PREFIX_.'philea_sync` - SET `status` = 2 - WHERE `id_sync` = '.(int) $row['id_sync'].' - LIMIT 1 - '); - /*system('cd '.dirname(__FILE__).'/script && php send_recep_orderform.php '.(int) $row['id_sale']);*/ + // SEND REC01 - pas de gestion recption fournisseur sur bbb + Db::getInstance()->ExecuteS(' + UPDATE `'._DB_PREFIX_.'philea_sync` + SET `status` = 2 + WHERE `id_sync` = '.(int) $row['id_sync'].' + LIMIT 1 + '); + /*system('cd '.dirname(__FILE__).'/script && php send_recep_orderform.php '.(int) $row['id_sale']);*/ + } } if($row = Db::getInstance()->getRow('