erp
This commit is contained in:
parent
78a2577c57
commit
37261e068c
@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user