示例#1
0
 public function GetDereferencement()
 {
     $domain = Configuration::get('PS_SHOP_DOMAIN');
     $cle = $this->tabConfig['ID_ECOPRESTO'];
     $filename = $this->fichierDerefDistant;
     include 'class/download.class.php';
     $download = new DownloadBinaryFile();
     $response = '';
     if ($download->load($filename) == true) {
         $download->saveTo('files/' . $this->fichierDeref);
         $contenu_fichier = Tools::file_get_contents('files/' . $this->fichierDeref);
         $lignesTot = substr_count($contenu_fichier, "\n");
         if ($lignesTot > 1) {
             $response = '1,' . $lignesTot;
         } else {
             $response = '0,<p>Aucun nouveau produit déréférencé.</p>';
         }
     } else {
         $response = '0,<p>Aucun nouveau produit déréférencé.</p>';
     }
     return $response;
 }
示例#2
0
include '../../config/settings.inc.php';
include '../../config/config.inc.php';
include dirname(__FILE__) . '/class/download.class.php';
include dirname(__FILE__) . '/class/catalog.class.php';
include dirname(__FILE__) . '/class/reference.class.php';
$download = new DownloadBinaryFile();
$catalog = new Catalog();
if (Tools::getValue('ec_token') != $catalog->getInfoEco('ECO_TOKEN')) {
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Location: ../");
    exit;
}
$trackingD = $catalog->getInfoEco('ECO_URL_TRACKING') . $catalog->tabConfig['ID_ECOPRESTO'];
$trackingL = 'files/tracking.xml';
if ($download->load($trackingD) == true) {
    $download->saveTo($trackingL);
    if (($handle = fopen($trackingL, 'r')) !== false) {
        while (($data = fgetcsv($handle, 10000, ';')) !== false) {
            $ne = 0;
            $ne = Db::getInstance()->getValue('SELECT `id` FROM `' . _DB_PREFIX_ . 'ec_ecopresto_tracking` WHERE `numero`="' . pSQL($data[3]) . '"');
            if ($ne == 0) {
                Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'ec_ecopresto_tracking` (`id_order`,`transport`,`numero`,`date_exp`,`url_exp`)
								VALUES (' . (int) $data[0] . ',"' . pSQL($data[2]) . '","' . pSQL($data[3]) . '","' . pSQL($data[4]) . '","' . pSQL($data[5]) . '")');
            }
        }
    }
}
示例#3
0
include dirname(__FILE__) . '/class/reference.class.php';
$download = new DownloadBinaryFile();
$catalog = new Catalog();
if (Tools::getValue('ec_token') != $catalog->getInfoEco('ECO_TOKEN')) {
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Location: ../");
    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));