コード例 #1
0
ファイル: stock.php プロジェクト: ventsiwad/presta_addons
    exit;
}
$stockD = $catalog->getInfoEco('ECO_URL_STOCK') . $catalog->tabConfig['ID_ECOPRESTO'];
$stockL = 'files/stock.xml';
if ($download->load($stockD) == true) {
    $download->saveTo($stockL);
    if (($handle = fopen($stockL, 'r')) !== false) {
        $etat = $catalog->updateMAJStock();
        while (($data = fgetcsv($handle, 10000, ';')) !== false) {
            $ref = $data[0];
            $qty = $data[1];
            $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);