<?php 

ini_set('display_errors',1);
$row = 1;
$produkty = [];
if (($handle = fopen("modules/EcmProducts/RECEPTURY.csv", "r")) !== FALSE) {
	while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
		$produkty[$data[1]]=$data;
	
	}
	fclose($handle);
}

$dostawcy=[
		'Brenntag'=>'2c64b602-e55e-d48b-51d1-59d73e624f5e',
		'Surchem'=>'802ca85d-b7f4-88f8-aeb4-59d73ea73d84',
		'Pollena Aroma'=>'836c6dc0-20a4-7224-2cdb-59d73ed811dd'
		
		
];
$jedn=[
		'litr'=>'7',
		'kg'=>2
];
echo "<pre>";
var_dump($produkty);

foreach ($produkty as $produkt){
	if($produkt[0]!=null){
		$p = new EcmProduct();
		$p->name=$produkt[0];
		$p->code=$produkt[1];
		$p->vendor_name=$produkt[2];
		$p->vendor_id=$dostawcy[$produkt[2]];
		$p->vat_id='28079566-b825-e38f-9993-4ccc7b781de5';
		$p->status='active';
		$p->assigned_user_id='1';
		$p->ks_group=1;
		$p->pieces_per_carton=$produkt[12];
		$p->unit_id=$jedn[$produkt[3]];
		$p->srp_price=$produkt[6];
		$p->product_category_id='2e920d37-8ab8-5197-567a-59d73c7e82fe';
		$p->product_category_name='Materiały AGD';
		$p->position_list3 = [
				0=>[
						'ecmproductcategory_id'=>'2e920d37-8ab8-5197-567a-59d73c7e82fe'
				]
		];
		echo "dodaje!@";
		$p->save();
	}

}
?>