modifica per preorder da disattivare (in Vendita)

This commit is contained in:
paoloar77
2024-07-08 12:12:24 +02:00
parent 965c997d30
commit 0b6e5f1af3

View File

@@ -274,6 +274,40 @@ function setPreOrder($sku, $aggiornapreordine, $debug)
echo "Aggiornato come Non Disponibile : [ParentId=" . $idprodotto . '] ProdId= ' . $product['id'] . ' ' . $variation['name'] . "<br>";
}
}
} 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 "<br>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'] . "<br>";
}
}
}
} 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) {