Exemplo n.º 1
0
 public function process_xml($type = "FOR_INSERT")
 {
     global $logger, $db;
     $this->store_products = $this->get_imported($this->name);
     $this->import_settings = Settings::get_import_settings($this->name);
     $fh = @fopen(FEED_PATH . "dealerpricelist.csv", "r");
     $art = fgetcsv($fh, null, ",");
     $i = 0;
     $bz = 0;
     $this->all = 0;
     return array();
     while (($art = fgetcsv($fh, null, ",")) !== false) {
         $sku = (string) trim($art[1]);
         $store_product_id = @$this->store_products[$sku];
         $this->all++;
         if ($type == "FOR_INSERT" && $store_product_id) {
             continue;
         }
         if ($type == "FOR_UPDATE" && !$store_product_id) {
             continue;
         }
         $item = new stdClass();
         $item->sku = $sku;
         $catname = ($art[8] != "" ? $art[8] : "") . ($art[9] != "" ? " > " . $art[9] : "") . ($art[10] != "" ? " > " . $art[10] : "");
         $catnametext = str_replace("\"", "``", $catname);
         $catnametext = str_replace("\"", "``", $catnametext);
         $catnametext = str_replace("'", "`", $catnametext);
         $item->category_XML = $catnametext;
         if (@$this->category_mapping[$item->category_XML]) {
             foreach ($this->category_mapping[$item->category_XML] as $catstore) {
                 // $d = $this->get_ps_category_ancestors($catstore);
                 // dump($d);exit;
                 // $item->category_ids[] = $this->get_ps_category_ancestors($catstore);
                 $item->category_ids[] = (int) $catstore;
             }
         }
         if (@count($item->category_ids) == 0) {
             //                echo $bz++ . ". {$sku} NO CATEGORY ({$item->category_XML}) <Br>";
             continue;
         }
         //$item->category_ids = array_unique($item->category_ids);
         //  dump($item->category_ids) ;exit;
         // part number
         // dump(explode(",",$this->import_settings['NOT_IMPORT_NAME']));exit;
         //if (in_array($item->sku, explode(",",$this->import_settings['NOT_IMPORT_SKU']))) continue;
         // 33,34
         $item->quantity = (int) $art[7];
         if (!$item->quantity) {
             //                echo $bz2++ . ". {$sku} QTY=0<Br>";
             continue;
         }
         //            if ($item->quantity < 10 ) continue;
         //                    if ($item->quantity < 10) continue;
         $item->title = $art[2];
         $item->desc_short = ImpLib::limitString($art[3]);
         $item->meta_desc = ImpLib::limitString($art[3]);
         $item->tags = "";
         $item->meta_keywords = "";
         $item->desc_long = $art[3];
         $item->vendor = $art[0];
         $item->plant = $art[0];
         $item->manufacturer = $art[0];
         $item->manufacturer_sku = $art[1];
         //$item->supplier_reference = $art[3];
         $item->manufacturer_sku_2 = $art[4];
         $item->store_product_id = $store_product_id;
         $item->supplier = "Dove";
         //            if ($type=="FOR_INSERT") {
         //                $item->id_manufacturer = $this->get_manufacturer_id($item->manufacturer);
         //                $item->manufacturer_id = $item->id_manufacturer;
         //            }
         $item->ean_upc = (string) $art[13];
         $item->price = (double) $art[6];
         //            $item->rrp = (float) (str_replace("$", "", $art[3]));;
         $item->raw_price = $item->price;
         if ($item->price < 0.1) {
             continue;
         }
         // echo Settings::get_margin_from_price($item->price);exit;
         $margin = @$this->import_settings['MARGIN'][$item->category_XML];
         //                    dump($this->import_settings['MARGIN']);exit;
         //dump($this->import_settings);
         $item->margin = $margin > 0 ? $margin : (int) $this->import_settings['GLOBALPROFITMARGIN'];
         //                    dump($item);exit;
         /// $item->margin  = ($margin !="") ? $margin : Settings::get_margin_from_price($item->price);
         $item->price_raw = $item->price;
         $item->price = $item->price * (1 + $item->margin / 100);
         $item->price = $item->price;
         $item->wholesale_price = $item->price_raw;
         $item->weight = "";
         $item->length = "";
         $item->width = "";
         $item->height = "";
         $item->active = 1;
         $item->_regular_price = $item->price;
         $item->_sale_price = "";
         $item->status = 1;
         $item->images = array();
         if ($art[11] != "") {
             $item->images[] = $art[11];
         } else {
             continue;
         }
         if ($sku == "PTH-851-K1-CX") {
             dump($item);
             dump($art);
             //                exit;
         }
         echo "{$item->sku} | {$item->category_XML} | {$item->price_raw} + {$item->margin}% => {$item->price}<br>";
         $articles_final[$sku] = $item;
         $i++;
     }
     //         dump($articles_final);exit;
     return @$articles_final;
 }
Exemplo n.º 2
0
 public function process_xml($type = "FOR_INSERT")
 {
     global $logger, $db;
     $this->store_products = $this->get_imported($this->name);
     $this->updatedIceCatItems = IceCat::getUpdatedIceCatItemsOK();
     $this->import_settings = Settings::get_import_settings($this->name);
     $fh = @fopen(FEED_PATH . $this->name . ".csv", "r");
     $art = fgetcsv($fh, null, "|");
     //            dump($art) ;
     $i = 0;
     $bz = 0;
     $this->all = 0;
     while (($art = fgetcsv($fh, null, "|")) !== false) {
         $sku = (string) trim($art[1]);
         // 0
         $store_product_id = @$this->store_products[$sku];
         $this->all++;
         if ($type == "FOR_INSERT" && $store_product_id) {
             continue;
         }
         if ($type == "FOR_UPDATE" && !$store_product_id) {
             continue;
         }
         // continue;
         $item = new stdClass();
         $item->sku = $sku;
         $item->category_XML = $art[10];
         // 4
         //            $logger->
         if (@$this->category_mapping[$item->category_XML]) {
             foreach ($this->category_mapping[$item->category_XML] as $catstore) {
                 $d = $this->get_category_ancestors($catstore);
                 //                            dump($d);exit;
                 if ($d != 0) {
                     //dump($d);
                     foreach ($d as $cc) {
                         $item->category_ids[] = (int) $cc;
                     }
                 }
                 $item->category_ids[] = (int) $catstore;
             }
         }
         if (@count($item->category_ids) == 0) {
             //echo $bz++ . ". {$sku} NO CATEGORY ({$item->category_XML}) <Br>";
             continue;
         }
         //$item->category_ids = array_unique($item->category_ids);
         //  dump($item->category_ids) ;exit;
         // part number
         // dump(explode(",",$this->import_settings['NOT_IMPORT_NAME']));exit;
         //if (in_array($item->sku, explode(",",$this->import_settings['NOT_IMPORT_SKU']))) continue;
         // 33,34
         $item->quantity = (int) $art[11];
         // 7
         if (!$item->quantity) {
             continue;
         }
         if ($item->quantity < 10) {
             continue;
         }
         //                    if ($item->quantity < 10) continue;
         $item->title = $art[4];
         // 3
         $item->desc_short = ImpLib::limitString($art[4]);
         // 3
         $item->meta_desc = ImpLib::limitString($art[4]);
         // 3
         $item->meta_keywords = ImpLib::limitString($art[4]);
         $item->tags = ImpLib::limitString($art[4]);
         $item->desc_long = $art[4];
         $item->vendor = $art[2];
         $item->plant = $art[2];
         $item->manufacturer = $art[2];
         // 1
         $item->manufacturer_sku = $art[3];
         // 2
         //$item->supplier_reference = $art[3];
         $item->manufacturer_sku_2 = $art[0];
         $item->store_product_id = $store_product_id;
         $item->supplier = "SY";
         // if ($type=="FOR_INSERT") {
         $item->manufacturer_id = $this->get_manufacturer_id($item->manufacturer);
         //  }
         $item->ean_upc = "";
         $item->price = (double) str_replace("\$", "", $art[7]);
         $item->rrp = (double) str_replace("\$", "", $art[7]);
         $item->raw_price = $item->price;
         if ($item->price < 0.1) {
             continue;
         }
         // echo Settings::get_margin_from_price($item->price);exit;
         $margin = @$this->import_settings['MARGIN'][$item->category_XML];
         //                    dump($this->import_settings['MARGIN']);exit;
         //dump($this->import_settings);
         $item->margin = $margin > 0 ? $margin : (int) $this->import_settings['GLOBALPROFITMARGIN'];
         //                    dump($item);exit;
         /// $item->margin  = ($margin !="") ? $margin : Settings::get_margin_from_price($item->price);
         $item->price_raw = $item->price;
         $item->price = $item->price * (1 + $item->margin / 100);
         //            $item->price = $item->price ;
         //              dump($item); dump($art);exit;
         $item->wholesale_price = $item->price_raw;
         $item->weight = "";
         $item->length = "";
         $item->width = "";
         $item->height = "";
         $item->active = 1;
         $item->status = 1;
         $item->images = array();
         if ($sku == "66016") {
             //            	dump($art);
             //            	dump($item);
             //           		exit;
         }
         if ($item->title == "Microsoft") {
             die("Bad feed. Contact support");
         }
         //            dump($art);
         //            dump($item);
         //           exit;
         //            echo "{$item->sku} | {$item->category_XML} | {$item->price_raw} + {$item->margin}% => {$item->price}<br>";
         $articles_final[$sku] = $item;
         $i++;
     }
     //         dump($articles_final);;
     return @$articles_final;
 }
Exemplo n.º 3
0
 public function process_xml($type = "FOR_INSERT")
 {
     global $logger, $db;
     $this->store_products = $this->get_imported($this->name);
     $this->import_settings = Settings::get_import_settings($this->name);
     $fh = @fopen(FEED_PATH . "CDL EPricefile.csv", "r");
     $art = fgetcsv($fh, null, ",");
     $i = 0;
     $bz = 0;
     $this->all = 0;
     //            dump($art);
     while (($art = fgetcsv($fh, null, ",")) !== false) {
         $sku = (string) trim($art[0]);
         $sku = str_replace("\\", "-", $sku);
         //            dump($art);exit;
         $store_product_id = @$this->store_products[$sku];
         $this->all++;
         if ($type == "FOR_INSERT" && $store_product_id) {
             continue;
         }
         if ($type == "FOR_UPDATE" && !$store_product_id) {
             continue;
         }
         $item = new stdClass();
         $item->sku = $sku;
         $item->category_XML = $art[3];
         if (@$this->category_mapping[$item->category_XML]) {
             foreach ($this->category_mapping[$item->category_XML] as $catstore) {
                 // $d = $this->get_ps_category_ancestors($catstore);
                 // dump($d);exit;
                 // $item->category_ids[] = $this->get_ps_category_ancestors($catstore);
                 $item->category_ids[] = (int) $catstore;
             }
         }
         if (@count($item->category_ids) == 0) {
             //                echo $bz++ . ". {$sku} NO CATEGORY ({$item->category_XML}) <Br>";
             continue;
         }
         $item->quantity = (int) $art[10];
         if (!$item->quantity) {
             //                echo $bz2++ . ". {$sku} QTY=0<Br>";
             continue;
         }
         //            if ($item->quantity < 10 ) continue;
         //                    if ($item->quantity < 10) continue;
         $item->title = $art[2];
         $item->desc_short = ImpLib::limitString($art[2]);
         $item->meta_desc = ImpLib::limitString($art[2]);
         $item->tags = "";
         $item->meta_keywords = "";
         $item->desc_long = $art[2];
         $item->vendor = $art[4];
         $item->plant = $art[4];
         $item->manufacturer = $art[4];
         $item->manufacturer_sku = $art[0];
         //$item->supplier_reference = $art[3];
         $item->manufacturer_sku_2 = $art[0];
         $item->store_product_id = $store_product_id;
         $item->supplier = "CDL";
         //            if ($type=="FOR_INSERT") {
         //                $item->id_manufacturer = $this->get_manufacturer_id($item->manufacturer);
         //                $item->manufacturer_id = $item->id_manufacturer;
         //            }
         $item->ean_upc = "";
         $item->price = (double) $art[9];
         //            $item->rrp = (float) (str_replace("$", "", $art[3]));;
         $item->raw_price = $item->price;
         if ($item->price < 0.1) {
             continue;
         }
         // echo Settings::get_margin_from_price($item->price);exit;
         $margin = @$this->import_settings['MARGIN'][$item->category_XML];
         //                    dump($this->import_settings['MARGIN']);exit;
         //dump($this->import_settings);
         $item->margin = $margin > 0 ? $margin : (int) $this->import_settings['GLOBALPROFITMARGIN'];
         //                    dump($item);exit;
         /// $item->margin  = ($margin !="") ? $margin : Settings::get_margin_from_price($item->price);
         $item->price_raw = $item->price;
         $item->price = $item->price * (1 + $item->margin / 100);
         $item->_regular_price = $item->price;
         $item->wholesale_price = $item->price_raw;
         $item->weight = "";
         $item->length = "";
         $item->width = "";
         $item->_sale_price = "";
         $item->_wc_cog_cost = "";
         $item->height = "";
         $item->active = 1;
         $item->status = 1;
         $item->images = array();
         $imgfile = IMPORT_ABS_PATH . "/CDL_temp_/Jpegs/" . str_replace("-", "", strtolower($item->sku)) . ".jpg";
         if (@filesize($imgfile) > 100) {
             $item->images = "http://www.bestdirect.co.nz/CDL_temp_/Jpegs/" . str_replace("-", "", strtolower($item->sku)) . ".jpg";
             //            	dump($item);exit;
         }
         //            dump($imgfile);exit;
         if ($sku == "A-U2AFMICBM") {
             //               	dump($item);
             //               	dump($art);
             //                exit;
         }
         echo "{$item->sku} | {$item->category_XML} | {$item->price_raw} + {$item->margin}% => {$item->price}<br>";
         $articles_final[$sku] = $item;
         $i++;
         //             dump($art);;
         //           dump($item);exit;
     }
     //         dump($articles_final);exit;
     return @$articles_final;
 }
Exemplo n.º 4
0
 public function process_xml($type = "FOR_INSERT")
 {
     global $logger, $db;
     $this->store_products = $this->get_imported($this->name);
     $this->updatedIceCatItems = IceCat::getUpdatedIceCatItemsOK();
     $this->import_settings = Settings::get_import_settings($this->name);
     $cached_ancestors = array();
     $fh = @fopen(FEED_PATH . "/215841.csv", "r");
     $art = fgetcsv($fh, null, "\t");
     //    dump($art) ;
     $i = 0;
     $bz = 0;
     $this->all = 0;
     while (($art = fgetcsv($fh, null, ",")) !== false) {
         //        	dump($art);exit;
         $sku = (int) trim($art[0]);
         if ($sku == "1520519") {
             continue;
         }
         $store_product_id = @$this->store_products[$sku];
         $this->all++;
         if ($type == "FOR_INSERT" && $store_product_id) {
             continue;
         }
         if ($type == "FOR_UPDATE" && !$store_product_id) {
             continue;
         }
         //  exit;
         if ($type == "FOR_UPDATE") {
             // if ( !$this->updatedIceCatItems[$sku] ) continue;
         }
         $item = new stdClass();
         $item->category_XML = $art[12];
         if (@$this->category_mapping[$item->category_XML]) {
             foreach ($this->category_mapping[$item->category_XML] as $catstore) {
                 if (isset($cached_ancestors[$catstore])) {
                     $d = $cached_ancestors[$catstore];
                 } else {
                     //                           	     $logger->LogCron(" - $catstore");
                     $cached_ancestors[$catstore] = $this->get_category_ancestors($catstore);
                     $d = $cached_ancestors[$catstore];
                     //							  $logger->LogCron(" - ok => " . print_r($d, true));
                 }
                 //                            dump($d);exit;
                 foreach ($d as $cc) {
                     $item->category_ids[] = (int) $cc;
                 }
                 $item->category_ids[] = (int) $catstore;
             }
         }
         if (@count($item->category_ids) == 0) {
             //echo $bz++ . ". {$sku} NO CATEGORY ({$item->category_XML}) <Br>";
             continue;
         }
         //$item->category_ids = array_unique($item->category_ids);
         //  dump($item->category_ids) ;exit;
         $item->sku = $sku;
         // part number
         // dump(explode(",",$this->import_settings['NOT_IMPORT_NAME']));exit;
         //if (in_array($item->sku, explode(",",$this->import_settings['NOT_IMPORT_SKU']))) continue;
         // 33,34
         $item->quantity = $art[16];
         if (!$item->quantity) {
             continue;
         }
         //                    if ($item->quantity < 10) continue;
         $item->title = $art[1];
         $item->desc_short = ImpLib::limitString($art[23]);
         $item->desc_long = $art[23];
         /*
           ['0'] = String(18) "Ingram Part Number"
         
                         |    ['2'] = String(20) "Customer Part Number" = 0
                         |    ['3'] = String(18) "Vendor Part Number"
                         |    ['6'] = String(13) "Vendor Number"
         *
         */
         $item->vendor = $art[7];
         $item->plant = $art[5];
         $item->manufacturer = $art[7];
         $item->manufacturer_sku = $art[3];
         $item->meta_desc = $item->desc_short;
         $item->meta_keywords = $item->desc_short;
         $item->tags = $item->desc_short;
         //$item->supplier_reference = $art[3];
         $item->manufacturer_sku_2 = $art[6];
         $item->store_product_id = $store_product_id;
         $item->supplier = "IM";
         //$db->query("UPDATE "._DB_PREFIX_."product_supplier SET id_supplier='{$item->id_supplier}' WHERE id_product='{$store_product_id}'");
         $item->manufacturer_id = $this->get_manufacturer_id($item->manufacturer);
         //dump($item);exit;
         if ($type == "FOR_INSERT") {
             //$item->id_manufacturer = $this->get_manufacturer_id($item->manufacturer);
             //$item->id_supplier = $this->get_supplier_id($art[4]);
         }
         $item->ean_upc = $art[4];
         $item->online_only = 0;
         $item->price = $art[13];
         $item->rrp = $art[14];
         $item->raw_price = $art[13];
         // customer price
         if ($item->price < 0.1) {
             continue;
         }
         // echo Settings::get_margin_from_price($item->price);exit;
         if ($i == 1500) {
             $db->query('UPDATE imported SET processed = 0 WHERE supplier="IMNZ"');
         }
         if ($i == 3000) {
             $db->query('UPDATE imported SET processed = 0 WHERE supplier="IMNZ"');
         }
         $margin = @$this->import_settings['MARGIN'][$item->category_XML];
         //                    dump($this->import_settings['MARGIN']);exit;
         //dump($this->import_settings);
         $item->margin = $margin > 0 ? $margin : (int) $this->import_settings['GLOBALPROFITMARGIN'];
         //                    dump($item);exit;
         /// $item->margin  = ($margin !="") ? $margin : Settings::get_margin_from_price($item->price);
         $item->price_raw = $item->price;
         $item->price = $item->price * (1 + $item->margin / 100);
         $item->price = $item->price;
         /// 1.15;
         //                     * 1.15;
         //                    $item->rrp = $item->rrp * 1.15;
         echo "{$item->sku} | {$item->category_XML} | {$item->price_raw} + {$item->margin}% => {$item->price}<br>";
         $item->wholesale_price = $art[13];
         if ($item->wholesale_price == 0) {
             continue;
         }
         $item->weight = (double) $art[9];
         $item->length = (double) $art[24];
         $item->width = (double) $art[25];
         $item->height = (double) $art[26];
         //                         dump($item);exit;
         $item->active = 1;
         $item->status = 1;
         $item->images = array();
         //if ($item->active == 0) continue;
         if ($sku == "2307809") {
             //                       dump($art);
             //                        dump($item);exit;
         }
         $articles_final[$sku] = $item;
         $i++;
         //                    echo $i . " | ";
         //break;
     }
     //  dump($articles_final);
     //  exit;
     return @$articles_final;
 }