From 37261e068c4d33be6b343f984a91b18c696a5ec1 Mon Sep 17 00:00:00 2001 From: Thibault UBUNTU Date: Thu, 7 Apr 2016 10:40:08 +0200 Subject: [PATCH] erp --- erp/erp_add_product.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/erp/erp_add_product.php b/erp/erp_add_product.php index fe6181b..3c392da 100644 --- a/erp/erp_add_product.php +++ b/erp/erp_add_product.php @@ -12,14 +12,21 @@ require 'config.php'; $models = ripcord::client("$url/xmlrpc/2/object"); +// date de diff pour la récupération produit +$date_since_import = new DateTime(); +$date_since_import->modify('-6 month'); + // get all salable products ids $ids_product = $models->execute_kw($db, $uid, $password, - 'product.template', 'search', [[['sale_ok', '=', true]]] + 'product.template', 'search', array( + array( + array('sale_ok', '=', 'true'), + array('create_date', '>=', $date_since_import->format('Y-m-d H:i:s')), + ) + ) ); - foreach ($ids_product as $key => $id) { - if (ErpTools::productAlreadyExists($id)) { continue; } @@ -29,15 +36,11 @@ foreach ($ids_product as $key => $id) { 'product.template', 'read', array($id) ); - $variants = $models->execute_kw($db, $uid, $password, 'product.product', 'read', [$record['product_variant_ids']] ); - try { - - $d = Db::getInstance(); $current_date = new DateTime(); @@ -244,11 +247,8 @@ foreach ($ids_product as $key => $id) { foreach ($attrs as $attr) { $sql = 'INSERT INTO '._DB_PREFIX_.'product_attribute_combination (id_attribute, id_product_attribute) VALUES('.pSQL($assoc_attr[$attr['id']]).', '.pSQL($id_product_attribute).')'; $d->execute($sql); - } - - } } catch (Exception $e) { @@ -256,4 +256,3 @@ foreach ($ids_product as $key => $id) { } } -