161 $stories = isset($fields[
'STORIES']) ? array_unique($fields[
'STORIES'], SORT_NUMERIC): array();
195 $value = mb_substr($replaceCurrency <>
''? $replaceCurrency : $traits[$k], 0, 3);
311 foreach ($items as $rowId=>$item)
313 foreach($info[
'FIELDS'] as $name=>$fieldInfo)
320 $value = static::normalizeExternalCode($item[
'PRODUCT_XML_ID']);
323 $value = $item[
'CATALOG_XML_ID'];
326 $value = $item[
'NAME'];
328 case 'PRICE_PER_UNIT':
329 $value = $item[
'PRICE'];
332 $value = $item[
'QUANTITY'];
335 $value = $item[
'PRICE']*$item[
'QUANTITY'];
338 $value = self::KOEF_DEFAULT;
341 $code = (intval($item[
'MEASURE_CODE'])>0 ? $item[
'MEASURE_CODE']:self::MEASURE_CODE_DEFAULT);
342 foreach($fieldInfo[
'FIELDS'] as $unitFieldName=>$unitFieldInfo)
345 switch ($unitFieldName)
347 case 'ITEM_UNIT_CODE':
350 case 'ITEM_UNIT_NAME':
351 $unitValue = static::getCatalogMeasureByCode($code);
354 $this->externalizeField($unitValue, $unitFieldInfo);
355 $fieldValues[$unitFieldName] = $unitValue;
359 $summ = doubleval($item[
'DISCOUNT_PRICE']);
362 foreach($fieldInfo[
'FIELDS'] as $discountFieldName=>$discountFieldInfo)
365 switch ($discountFieldName)
371 $discountValue = $item[
'DISCOUNT_PRICE'];
374 $discountValue =
'Y';
377 $this->externalizeField($discountValue, $discountFieldInfo);
378 $fieldValues[$discountFieldName] = $discountValue;
383 foreach($fieldInfo[
'FIELDS'] as $rekFieldName=>$rekFieldInfo)
386 switch ($rekFieldName)
388 case 'TYPE_NOMENKLATURA':
389 foreach ($rekFieldInfo[
'FIELDS'] as $nameProp=>$infoProp)
401 $this->externalizeField($valueProp, $infoProp);
402 $fieldValue[$nameProp] = $valueProp;
404 $fieldValues[] = $fieldValue;
406 case 'TYPE_OF_NOMENKLATURA':
407 foreach ($rekFieldInfo[
'FIELDS'] as $nameProp=>$infoProp)
419 $this->externalizeField($valueProp, $infoProp);
420 $fieldValue[$nameProp] = $valueProp;
422 $fieldValues[] = $fieldValue;
424 case 'BASKET_NUMBER':
425 foreach ($rekFieldInfo[
'FIELDS'] as $nameProp=>$infoProp)
434 $valueProp = \CSaleExport::getNumberBasketPosition($item[
'ID']);
437 $this->externalizeField($valueProp, $infoProp);
438 $fieldValue[$nameProp] = $valueProp;
440 $fieldValues[] = $fieldValue;
442 case 'PROPERTY_VALUE_BASKET':
443 $attributes = isset($item[
'ATTRIBUTES'])? $item[
'ATTRIBUTES']:array();
444 if(count($attributes)>0)
446 foreach ($attributes as $rowIdAttr=>$attribute)
448 foreach ($rekFieldInfo[
'FIELDS'] as $nameProp=>$infoProp)
457 $valueProp = $attribute[
'VALUE'];
460 $this->externalizeField($valueProp, $infoProp);
461 $fieldValues[$rowIdAttr][$nameProp] = $valueProp;
470 $rate = doubleval($item[
'VAT_RATE']);
473 foreach($fieldInfo[
'FIELDS'] as $rateFieldName=>$rateFieldInfo)
476 switch ($rateFieldName)
482 $rateValue = $item[
'VAT_RATE']*100;
485 $this->externalizeField($rekValue, $rateFieldInfo);
486 $fieldValues[$rateFieldName] = $rateValue;
491 $rate = doubleval($item[
'VAT_RATE']);
494 foreach($fieldInfo[
'FIELDS'] as $taxFieldName=>$taxFieldInfo)
497 switch ($taxFieldName)
503 $taxValue = (($item[
"PRICE"] / ($item[
"VAT_RATE"]+1)) * $item[
"VAT_RATE"]);
509 $this->externalizeField($taxValue, $taxFieldInfo);
510 $fieldValues[$taxFieldName] = $taxValue;
518 $this->externalizeField($value, $fieldInfo);
519 $result[$rowId][$name] = $value;
521 elseif (is_array($fieldValues))
523 $result[$rowId][$name] = $fieldValues;
541 foreach ($stories as $store)
543 $store = static::getStoreById($store[
'ID']);
545 $resultStores=array();
546 foreach($info[
'FIELDS'] as $name=>$fieldInfo)
552 $value = $store[
'XML_ID'];
555 $value = $store[
'TITLE'];
558 if(isset($store[
'ADDRESS']))
559 $value = $converterProfile->externalizeArrayFields(array(
'STREET'=>$store[
'ADDRESS']), $fieldInfo);
562 if(isset($store[
'PHONE']))
563 $value = $converterProfile->externalizeArrayFields(array(
'WORK_PHONE_NEW'=>$store[
'PHONE']), $fieldInfo);
566 if(!is_array($value))
567 $this->externalizeField($value, $fieldInfo);
568 $resultStores[$name] = $value;
570 $result[] = $resultStores;