...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_external_sale_import.php
- Класс: \CCrmExternalSaleImport
- Вызов: CCrmExternalSaleImport::ParseOrderDataOrderItems
private function ParseOrderDataOrderItems($document, $arSettings, &$arOrder) { if(!(is_array($document) && is_array($document["Item"]))) { return; } $arOrder["ITEMS"] = array(); foreach ($document["Item"] as $arItem) { $arItem = $arItem["#"]; $arResultTmp = array(); foreach ($arItem as $key => $value) { $value = $value[0]["#"]; switch ($key) { case 'Id': $arResultTmp["ID"] = $value; break; case 'ItemName': $arResultTmp["NAME"] = $value; break; case 'Amount': case 'ItemPrice': if (!isset($arResultTmp["PRICE"])) { $priceTotal = (float)str_replace($arSettings["SumFormat"]["CRD"], ".", $arItem["Amount"][0]["#"]); $priceUnit = (float)str_replace($arSettings["SumFormat"]["CRD"], ".", $arItem["ItemPrice"][0]["#"]); $quantity = (float)str_replace($arSettings["QuantityFormat"]["CRD"], ".", $arItem["Quantity"][0]["#"]); $price = $priceTotal; if ($quantity > 0) { $price /= $quantity; } $discountPrice = 0; if ($priceUnit != $price) { $discountPrice = $priceUnit - $price; } $arResultTmp["PRICE"] = $price; $arResultTmp["DISCOUNT_PRICE"] = $discountPrice; } break; case 'Quantity': $arResultTmp["QUANTITY"] = str_replace($arSettings["QuantityFormat"]["CRD"], ".", $value); break; case 'PropertiesValues': if (is_array($value["ItemProperty"])) { foreach ($value["ItemProperty"] as $v) $arResultTmp["PROPERTIES"][$v["#"]["ItemName"][0]["#"]] = $v["#"]["Value"][0]["#"]; } break; case 'Taxes': $taxValueTmp = $value["Tax"][0]["#"]["TaxValue"][0]["#"]; $arResultTmp["VAT_RATE"] = $taxValueTmp / 100; $arResultTmp["VAT_NAME"] = $value["Tax"][0]["#"]["Name"][0]["#"]; break; default: $arResultTmp[$key] = $value; break; } } $arOrder["ITEMS"][] = $arResultTmp; } }