diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index 335c3ab9..e17706db 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -274,6 +274,40 @@ function setPreOrder($sku, $aggiornapreordine, $debug) echo "Aggiornato come Non Disponibile : [ParentId=" . $idprodotto . '] ProdId= ' . $product['id'] . ' ' . $variation['name'] . "
"; } } + } else if ($aggiornapreordine === '0') { + if ($idprodotto > 0) { + + $variations = Variation::all($product['parent_id']); + if ($debug) + showarray($variations); + for ($i = 0; $i < count($variations); $i++) { + $variation = $variations[$i]; + if ($variation->id == $product['id']) { + // convert object into array + $data = json_decode(json_encode($variation), true); + break; + } + } + + $agg = true; + $data['meta_data'] = $product['meta_data']; + if ($agg) { + updateValueByKey($data['meta_data'], $campoPreOrder, 'no'); + updateValueByKey($data['meta_data'], '_is_pre_order', 'no'); + } + + if ($debug) { + echo "
Dati da Salvare:"; + showarray($data); + } + + $variation = Variation::update($idprodotto, $product['id'], $data); + + if ($variation) { + if ($debug) + echo "Aggiornato come in Vendita : [ParentId=" . $idprodotto . '] ProdId= ' . $product['id'] . ' ' . $variation['name'] . "
"; + } + } } } else { if ($debug) @@ -1570,6 +1604,9 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger) if ($inprevendita) { setPreOrder($article->IdArticolo, "1", false); $productLogger->addLog('pre_order', $article->titolo . ' [' . $article->IdArticolo . '] Impostato IN PREVENDITA !' . "\n"); + } else { + setPreOrder($article->IdArticolo, "0", false); + $productLogger->addLog('mettilo in Vendita (no pre-order)', $article->titolo . ' [' . $article->IdArticolo . '] Impostato IN VENDITA !' . "\n"); } } } catch (\Exception $e) {