$reference = new importerReference($ref); if (isset($reference->id_product) && $reference->id_product > 0) { if (version_compare(_PS_VERSION_, '1.5', '>=')) { if ($reference->id_product_attribute) { $allAT = importerReference::getAllProductIdByReference($ref); if (count($allAT) < 1) { $allAT[] = 0; } foreach ($allAT as $att) { StockAvailable::setQuantity((int) $reference->id_product, (int) $att, (int) $qty, (int) getShopForRef($att, 1)); } } else { StockAvailable::setQuantity((int) $reference->id_product, 0, (int) $qty, (int) getShopForRef($ref, 2)); } } else { updateProductQuantity($reference->id_product, $reference->id_product_attribute, $qty); } } } $catalog->updateMAJStock($etat); } } function getShopForRef($id, $typ) { $shop = Db::getInstance()->getValue('SELECT `id_shop` FROM `' . _DB_PREFIX_ . 'stock_available` WHERE id_product' . ($typ = 1 ? '_attribute' : '') . '=' . (int) $id); if (!isset($shop) || $shop == 0) { return 1; } else { return $shop; } }
function updateProduct(&$product) { updateProductQuantity($product); updateProductCost($product); }