Example #1
0
    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);
Example #2
0
													FROM `' . _DB_PREFIX_ . 'ec_ecopresto_lang_shop`
													WHERE `id_shop`=' . (int) $id_shop);
foreach ($lstLang as $lang) {
    $tabLang[$lang['id_lang']] = $lang['id_lang_eco'];
}
$lstAttr = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT `value`, `id_attribute`
													FROM `' . _DB_PREFIX_ . 'ec_ecopresto_attribute_shop` s, `' . _DB_PREFIX_ . 'ec_ecopresto_attribute` a
													WHERE s.`id_attribute_eco` = a.`id_attribute_eco`
													AND `id_shop`=' . (int) $id_shop);
foreach ($lstAttr as $Attr) {
    $tabAtt[$Attr['value']] = $Attr['id_attribute'];
}
foreach ($lstPdt as $pdt) {
    $pdt_final = array();
    if (time() - $time <= $catalog->limitMax) {
        $reference = new importerReference($pdt['thereference']);
        $pdt_final['id_product'] = (int) $reference->id_product;
        if ($pdt['imported'] == 1 && $pdt_final['id_product']) {
            $import->deleteProduct($reference->id_product, $pdt['thereference'], $pdt['id_shop']);
            Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'ec_ecopresto_product_imported` WHERE `reference`= "' . pSQL($pdt['thereference']) . '"');
            $etp++;
        } elseif ($pdt['imported'] == 1 && !$reference->id_product) {
            Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'ec_ecopresto_product_imported` WHERE `reference`= "' . pSQL($pdt['thereference']) . '"');
            Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'ec_ecopresto_product_shop` SET `imported`=2 WHERE `reference`= "' . pSQL($pdt['thereference']) . '" AND `id_shop`=' . (int) $pdt['id_shop']);
            $etp++;
        } elseif ($reference->id_product && $catalog->tabConfig['PARAM_MAJ_NEWPRODUCT'] == 1 && !$reference->getShopProduct($pdt['id_shop'], $reference->id_product)) {
            $etp++;
        } else {
            $tempRate = $pdt['rate'] / 1;
            $id_tax = isset($tabTax['id_tax'][(string) $tempRate]) ? (int) $tabTax['id_tax'][(string) $tempRate] : 0;
            $pdt_final['upd_index'] = (int) $catalog->tabConfig['PARAM_INDEX'];