HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 8.2.27
Disabled: NONE
Upload Files
File: /home/temp/yarusvl.ru/exchanger/ebazar_product.php
<?php
/**
 * Created by el.
 * @autor: el
 * @pakage: el
 * @version: 0.1 13.08.18 15:12
 * Date: 13.08.18
 */
 
/*chdir("..");*/
/*define("RP",str_replace("/exchanger","",dirname(__FILE__)).DIRECTORY_SEPARATOR);*/
require_once('config.php');

$mgc = new Mgc();
error_reporting(E_ALL);
ini_set("display_errors",1);


$xml = validationXML(SOURCE_DIR."ebazar_products.xml");


$importSupplier = new importSupplier(13);

$CATS = array();

foreach($xml->categories->category as $item) {



    $cdata = array(
 			    'supplier_id'=>13,
                'title'=>(string)$item["title"],
                "parent_id"=>(string)$item['parent_id'],
                "sup_id"=>(string)$item["id"]
                // id 	supplier_id 	title 	sup_id 	parent_id 	cat_id
             );

 $cat_id = $importSupplier->import_inner_category($cdata);

    $CATS[(int)$item["id"]] = (int)$cat_id;


	if((string)$item["id"]==109 || (string)$item['parent_id']==109) $cat['e'][(string)$item["id"]] = (string)$item["title"];
	if((string)$item["id"]==99 || (string)$item['parent_id']==99) $cat['r'][(string)$item["id"]] = (string)$item["title"];
	if((string)$item["id"]==411 || (string)$item['parent_id']==411) $cat['a'][(string)$item["id"]] = (string)$item["title"];
	if((string)$item["id"]==268 || (string)$item['parent_id']==268) $cat['ac'][(string)$item["id"]] = (string)$item["title"];
	if((string)$item["id"]==145 || (string)$item['parent_id']==145) $cat['up'][(string)$item["id"]] = (string)$item["title"];
	//$cat[(string)$item["id"]] = (string)$item["title"];
	//$parents[(string)$item['parent_id']][] = (string)$item["id"];

	}


		foreach($xml->categories->category as $item) {


	if(isset(    $cat['e'][(string)$item['parent_id']]   )  ) $cat['e'][(string)$item["id"]] =(string)$item["title"];
	if(isset(    $cat['r'][(string)$item['parent_id']]   ) ) $cat['r'][(string)$item["id"]] = (string)$item["title"];
	if(isset(    $cat['a'][(string)$item['parent_id']]   ) ) $cat['a'][(string)$item["id"]] =(string)$item["title"];

	if(isset(    $cat['ac'][(string)$item['parent_id']]   ) ) $cat['ac'][(string)$item["id"]] =(string)$item["title"];
	if(isset(    $cat['up'][(string)$item['parent_id']]   ) ) $cat['up'][(string)$item["id"]] =(string)$item["title"];
	//$cat[(string)$item["id"]] = (string)$item["title"];
	//$parents[(string)$item['parent_id']][] = (string)$item["id"];

	}


foreach ($xml->products->product as $item){
    $import =  new stdClass;

    if(isset($CATS[(int)$item->category_id]) && intval($CATS[(int)$item->category_id])){
        $import->category_id =  intval($CATS[(int)$item->category_id]);
    }else{
        $import->category = "Неразобранное";
    }

                $categ_id = (string)$item->category_id;
    			$import->name     = (string)$item->title;

    			$import->sku  = (string)$item->articul;
    			$import->description    = strlen((string)$item->description)?(string)$item->description:"<p></p>";
    			$import->brand    = (string)$item->brand;
    			$import->price    = str_replace(".","",(string)$item->price)/100;
    			//var_dump($import->price);exit;
    			$import->supplier_cat_id = intval($categ_id);
    			if(isset($cat['e'][$categ_id])){$import->weight   = 450/1000;}
    			elseif(isset($cat['r'][$categ_id])){$import->weight   = 35/1000;}
    			elseif(isset($cat['a'][$categ_id])){$import->weight   = 300/1000;}
    			elseif(isset($cat['ac'][$categ_id])){$import->weight   = 500/1000;}
    			elseif(isset($cat['up'][$categ_id])){$import->weight   = 800/1000;}
    			else{$import->weight   = null;}

$import->supplier_id=13;

    			$import->material = null;
    			$import->size     = (string)$item->size;
    			$import->color    = (string)$item->color;
    			//$import->id       = null;
    			$import->images   = [];

    			if($item->middle_image) {
    				$import->images[] = (string)$item->middle_image;
    			}
    			foreach($item->add_images->image as $image) {
    				$import->images[] = (string)$image;
    			}






$data = $importSupplier->import_item($import);


echo "import OK ".$import->name."[".$import->sku."]".PHP_EOL;
}

$importSupplier->setInactive();