Example #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;
 }
Example #2
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;
 }
Example #3
0
    public static function displayCategoryMappingTool()
    {
        global $b2b, $AUTOMAP, $logger, $db, $iconf;
        $b2b->import_settings = Settings::get_import_settings($b2b->name);
        ?>
         <table border="0" cellpadding="0" cellspacing="0" width="1200">
            <tr class='tableheader2' style="display: none;"><td colspan="3">Category Mapping Tool
            <div class="info1"><img src="<?php 
        echo IMPORT_BASE_URL . IMPORT_PATH;
        ?>
/assets/info.png" /></div>
            </td></tr>
            <tr class='tableheader'><td width='650'><?php 
        echo _t("Supplier's category");
        ?>
</td><?php 
        foreach ($iconf['SettingsPerCategory'] as $colname => $sett) {
            echo "<td>{$colname}</td>";
        }
        ?>
<td width='30'></td><td width='550'><?php 
        echo _t("Store category");
        ?>
</td></tr>

        <?php 
        $store_categories = $b2b->get_store_categories();
        $b2b->store_categories_simple = $b2b->get_store_categories_simple();
        echo Settings::get_selector($store_categories, 0, 0);
        // $category_mapping = $b2b->get_category_mapping_tree();
        if ($AUTOMAP) {
            $category_mapping = $b2b->get_category_mapping_tree();
        } else {
            $category_mapping = $b2b->get_category_mapping_tree();
        }
        $b2b->import_category_mapping = Settings::get_category_mappings($b2b->name);
        if (isset($b2b->import_category_mapping)) {
            foreach ($b2b->import_category_mapping as $feed_category_id => $store_category_ids) {
                foreach ($store_category_ids as $store_category_id) {
                    if (!isset($b2b->store_categories_simple[$store_category_id])) {
                        // the mapped category not exists
                        $db->query("DELETE FROM import_category_settings WHERE store_category_id='{$store_category_id}'");
                        $logger->LogCron("     - REMOVED store_category {$store_category_id} from settings.");
                    }
                }
            }
        }
        $b2b->import_category_mapping = Settings::get_category_mappings($b2b->name);
        foreach ($category_mapping as $cm) {
            if (!isset($cm['id'])) {
                continue;
            }
            $id = $cm['id'];
            if (!$id) {
                continue;
            }
            if (strlen($cm['name']) < 2) {
                continue;
            }
            $feed_category_id_from_settings = $selectors = "";
            if (@$b2b->import_category_mapping[$id]) {
                foreach ($b2b->import_category_mapping[$id] as $feed_category_id_from_settings) {
                    $selectors .= Settings::get_virtual_selector($b2b->store_categories_simple, $feed_category_id_from_settings, $id) . "<br />";
                }
            }
            $b2b->parent_feed_category_id_from_settings = @$feed_category_id_from_settings;
            if (!@$selectors) {
                $selectors = Settings::get_virtual_selector($b2b->store_categories_simple, $feed_category_id_from_settings, $id);
            }
            // alespon choose
            $addcatmap = '<div class="addcatmap" feedID="' . $id . '" >+</div>';
            // $selector = Settings::get_virtual_selector($b2b->store_categories_simple, $feed_category_id_from_settings, $id);
            $button_add_new_category = $feed_category_id_from_settings == "" || $feed_category_id_from_settings == "0" ? '<span class="new_cat_mapped" newcatname="' . addslashes(str_replace("\"", "'", $cm['name'])) . '" newcatid="' . $id . '" newparentid="0" >=></span>' : "";
            if (@$b2b->feed_category_counts[$id]) {
                $count = "(" . $b2b->feed_category_counts[$id] . ")";
            } else {
                $count = "";
            }
            $p2dset = "";
            if (isset($iconf['SettingsCategoryProducts'])) {
                foreach ($iconf['SettingsCategoryProducts'] as $setTitle => $setValues) {
                    $p2dset .= "<div class='p2dset p2dset_{$setValues['code']}' category_feed_id='{$id}' SetTitle='{$setTitle}' product_settings_type='{$setValues['code']}'><img src='" . IMPORT_BASE_URL . IMPORT_PATH . "/assets/{$setValues['icon']}' alt='{$setTitle}' /></div><div opened='0' class='p2dset_{$setValues['code']}_{$id} p2dsetbox'></div>";
                }
            }
            echo "<tr class='trmaincategory'><td class='maincategory'><h4 class='h4s'>" . $cm['name'] . " {$count}</h4><span class='corner'>{$p2dset}</span><div style='clear:both'></div></td>";
            foreach ($iconf['SettingsPerCategory'] as $colname => $sett) {
                echo "<td><input class='{$sett['class']}' code='{$sett['code']}' type='text' category_feed_id='{$id}' value='" . (@$b2b->import_settings[$sett['code']][$id] != "" ? $b2b->import_settings[$sett['code']][$id] : "") . "' size='{$sett['size']}'></td>";
            }
            echo "<td>{$button_add_new_category} {$addcatmap}</td><td class='selectors_{$id}'>{$selectors}</td></tr>";
            if ($AUTOMAP && ($feed_category_id_from_settings == "" || $feed_category_id_from_settings == "0")) {
                Settings::automapCategory($cm['name'], $id);
            }
            if (isset($cm['sub'])) {
                //            	Settings::_printSubCats($cm['sub']);
            }
        }
        ?>
        </table>

    <script language="JavaScript">
    <!--
      var supplier = '<?php 
        echo $b2b->name;
        ?>
';
      var ajaxloader = "<img style='margin-left:3px; border:0px solid #000;' src='<?php 
        echo IMPORT_BASE_URL . IMPORT_PATH;
        ?>
/assets/ajax-loader.gif' />";
      var feedID = 0;
      var product_settings_type = "";

      $(".selector").hide();

      init();

      var virtual_selector = "";

      function init_p2dset() {

          $('.save_products').click(function() {
               var skus = new Array();
               //$(".p2dset_" + feedID).html(ajaxloader  + "<br>" + $(".p2dset_" + feedID).html());
               $('.save_products').hide(20);
               $('.save_products').show(20);
               $('.p2dset_checkbox:checkbox:checked').each(function () {
                   var sThisVal = (this.checked ? $(this).val() : "");
                   skus.push(this.name);
               })

               var data = { 'category_feed_id':   feedID, 'supplier': supplier, 'skus':skus, 'product_settings_type': product_settings_type, 'to_do': "SAVE_CATEGORY_PRODUCTS_SETTINGS" };
               $.ajax({ type: 'post', cache: false, url: '<?php 
        echo CATEGORY_MAPPING_URL_AJAX;
        ?>
', data: data, success: function(data){
                  $(".p2dset_"  + product_settings_type + "_" + feedID).html(data);

                  init_p2dset();

               }
               })

          })

          $('.all_products').click(function() {  $('.p2dset_checkbox:checkbox').each(function () { this.checked = "checked";   }); })
          $('.no_products').click(function() { $('.p2dset_checkbox:checkbox').each(function () { this.checked = ""; }); })
      }

      $('.p2dset').click(function() {
           var e = $(this);
           feedID = e.attr("category_feed_id");
           SetTitle = e.attr("SetTitle");
           product_settings_type = e.attr("product_settings_type");
           $(".p2dsetbox").html("");
           $(".p2dset_" + product_settings_type + "_" + feedID).html(ajaxloader);
           //var parent = $('.virtual_selector[category_feed_id="'+feedID+'"]').html();
           //e.append("<br /><span class='virtual_selector' category_feed_id='" + feedID + "' category_oc_id=''>" + parent + "</span>");
           if ($(".p2dset_" + product_settings_type + "_" + feedID).attr("opened") != 1) {
               var data = { 'category_feed_id':   feedID, 'supplier': supplier, 'product_settings_type': product_settings_type,'to_do': "GET_CATEGORY_PRODUCTS_SETTINGS" };
                    $.ajax({ type: 'post', cache: false, url: '<?php 
        echo CATEGORY_MAPPING_URL_AJAX;
        ?>
', data: data, success: function(data){

                        if (data!="empty") {
	                        $(".p2dset_" + product_settings_type + "_" + feedID).html(data);
	                        $(".p2dset_" + product_settings_type + "_" + feedID).attr("opened", 1);
	                        $("#SetTitle").html(SetTitle);
	                        init_p2dset();
						}  else {
							alert("This category is empty");
							$(".p2dset_"  + product_settings_type + "_"+ feedID).html("");
						}
                    }
               })
           } else {
               $(".p2dset_" + product_settings_type + "_" + feedID).attr("opened", 0);
               $(".p2dset_" + product_settings_type + "_" + feedID).html("");
               feedID = 0;
           }
      })

      $('.addcatmap').click(function() {
           var e = $(this);
           var feedID = e.attr("feedID");

           var parent = $('.virtual_selector[category_feed_id="'+feedID+'"]').html();
           $('.selectors_' + feedID).append("<br /><span class='virtual_selector' category_feed_id='" + feedID + "' category_oc_id=''>" + parent + "</span>");
           init();
      })



         /**************************************** AUTOMAP THE CATEGORY **********************************/
          $('.new_cat_mapped').click(function() {
              var newcatname = $(this).attr("newcatname");
              var newcatid = $(this).attr("newcatid");
              var newparentid = $(this).attr("newparentid");
              var loader = jQuery("#loader").html();
              jQuery(this).html(ajaxloader);
              var data = { 'newcatname':   newcatname,
                        'newcatid':   newcatid,
                        'supplier':   supplier,
                        'newparentid':   newparentid,
                        'to_do': "ADD_NEW_CATEGORY" };
               $.ajax({ type: 'post', cache: false, url: '<?php 
        echo CATEGORY_MAPPING_URL_AJAX;
        ?>
', data: data, success: function(data){
                 if (data=="ok") {
                          location.href='<?php 
        echo CATEGORY_MAPPING_URL;
        ?>
';
                      //alert(data);
                 }
               }
               })
          })

       function init() {
       /**************************************** CHANGE THE CATEGORY MAPPING ******************/
          $('.virtual_selector').click(function() {
              virtual_selector = $(this);
              var category_oc_id = $(this).attr("category_oc_id");
              $(this).attr("category_oc_id", 0);   // dulezite pro nasl. fci
              var category_feed_id = $(this).attr("category_feed_id");
              var new_selector = $(".selector").insertAfter($(this));
               $(".selector").show()
               new_selector.attr("category_oc_id", category_oc_id) ;
               new_selector.attr("category_feed_id", category_feed_id) ;
               new_selector.val(category_oc_id);
          })
      }


      /**************************************** CATEGORY *************************************/
      $(".selector").change(function() {
            var this_selector = $(this);
            var category_oc_id = $(this).val();
            var category_feed_id = $(this).attr("category_feed_id");
            $('.virtual_selector[category_feed_id="'+category_feed_id+'"]').each(function (index) {
                cat =  $( this ) . attr("category_oc_id");
                if ( (cat != "0") && (cat != "") ){
                    category_oc_id = category_oc_id + "," + cat;
                }
            })
           var data = { 'category_feed_id':   category_feed_id,
                'category_oc_id':   category_oc_id,
                'supplier':   supplier,
                'to_do': "SAVE_CATEGORY_SETTINGS" };
           $.ajax({ type: 'post', cache: false, url: '<?php 
        echo CATEGORY_MAPPING_URL_AJAX;
        ?>
', data: data, success: function(data){
                 if (data=="ok") {
                       if (category_oc_id==0) {
                        virtual_selector.html("<span class='not_selected'>[ Choose... ]</span>");
                        // $('.virtual_selector[category_feed_id="'+category_feed_id+'"]').html("<span class='not_selected'>[ Choose... ]</span>");
                       } else {
                         //   $('.virtual_selector[category_feed_id="'+category_feed_id+'"]').html(this_selector.find("option:selected").text());
                            virtual_selector.html(this_selector.find("option:selected").text());
                           // $('.virtual_selector[category_feed_id="'+category_feed_id+'"]').attr('category_oc_id', this_selector.val());
                            virtual_selector.attr('category_oc_id', this_selector.val());
                     }
                       this_selector.hide(200);
                 } else {alert("Problem - contact the administrator !!!");}
              }
           });
      })

      /**************************************** SettingsPerCategory *************************************/
      $(".SettingsPerCategory").change(function() {
            var value = $(this).val();
            var category_feed_id = $(this).attr("category_feed_id");
            var code = $(this).attr("code");
            var this_selector = $(this);
            this_selector.hide(200);
            var data = { 'category_feed_id':   category_feed_id,
                'code':   code,
                'value':   value,
                'supplier':   supplier,
                'to_do': "SAVE_SETTINGS_PER_CATEGORY" };

            $.ajax({ type: 'post', cache: false, url: '<?php 
        echo CATEGORY_MAPPING_URL_AJAX;
        ?>
', data: data, success: function(data){
                 if (data=="ok") {
                     this_selector.show(200);
                 } else {
                     alert("Problem - contact the administrator !!!");
                 }
              }
           });
      })

      jQuery('.info1').click(function() {
        jQuery('.infobox1').bPopup({ opacity: 0.6, modalClose: true, follow: [10, 10] });
      })
      //-->
      </script>
    <?php 
    }
Example #4
0
<?php

$import_settings = Settings::get_import_settings($b2b->name);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="<?php 
echo IMPORT_BASE_URL . IMPORT_PATH;
?>
/assets/jquery.js"></script>
        <script type="text/javascript" src="<?php 
echo IMPORT_BASE_URL . IMPORT_PATH;
?>
/assets/jquery.bpopup.min.js"></script>
        <script type="text/javascript" src="<?php 
echo IMPORT_BASE_URL . IMPORT_PATH;
?>
/assets/jquery.hashchange.min.js"></script>
        <script type="text/javascript" src="<?php 
echo IMPORT_BASE_URL . IMPORT_PATH;
?>
/assets/jquery.easytabs.min.js"></script>
        <link rel="stylesheet" type="text/css" href="<?php 
echo IMPORT_BASE_URL . IMPORT_PATH;
?>
/assets/style.min.css" />
    </head>
    <body>
        <h1><?php 
Example #5
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;
 }
Example #6
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;
 }