Merge branch 'ticket-14485-phileaMultiSingle' into develop

This commit is contained in:
Marion Muszynski 2017-11-30 14:43:45 +01:00
commit 1bd2788bd7

View File

@ -9,7 +9,7 @@ include( dirname(__FILE__) . '/../philea_magistor.php');
ini_set('memory_limit', '4G');
$id_sale = (int) $argv[1];
$mode = isset($argv[2])?$argv[2]:0;
$mode = isset($argv[2])?(int)$argv[2]:0;
$_id_shipping = 1; // philea
@ -121,26 +121,32 @@ if($magistorModule->active) {
$sent_order = array();
foreach($orders as $o) {
$order = new Order($o['id_order']);
$sales = array();
$sales[(int)$id_sale] = (int) $id_sale;
$products = $order->getProducts();
// ANTADIS
$products_ids = array();
foreach($products as $product) {
if(!Db::getInstance()->getRow('
SELECT `id_product`
$product_sale = Db::getInstance()->getRow('
SELECT `id_sale`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $id_sale.'
AND `id_product` = '.(int) $product['product_id'].'
') && $mode==1) {
WHERE `id_product` = '.(int) $product['product_id'].'
');
if((int)$product_sale['id_sale'] != (int)$id_sale && $mode==1) {
// si multi et que le mode est à 1 (envoi uniquement des singles) on ne gère pas la commande
continue 2;
}
$sales[(int)$product_sale['id_sale']] = (int)$product_sale['id_sale'];
$products_ids[] = (int) $product['product_id'];
}
if(count($sales) == 1 && $mode == 2){
// si single et que le mode est à 2 (envoi uniquement des multis) on ne gère pas la commande
continue;
}
$sent_order[] = $o['id_order'];
$sales = array();
$sales[(int)$id_sale] = (int) $id_sale;
$nbProducts = 0;
$nbProducts = (int) Db::getInstance()->getValue('