fix create orders (#7)

* [productId] replace to [offer][externalId]
* properties for items in order and in icml
This commit is contained in:
DmitryZagorulko 2017-03-21 12:46:37 +04:00 committed by Alex Lushpai
parent b61379cabc
commit 6eed3ad0e7
3 changed files with 44 additions and 4 deletions

View File

@ -143,7 +143,8 @@ $products = $orderInstance->getProducts();
foreach($products as $product) {
$item = array(
'productId' => $product['product_id'],
//'productId' => $product['product_id'],
'offer' => array('externalId' => $product['product_id']),
'productName' => $product['product_name'],
'quantity' => $product['product_quantity'],
'initialPrice' => round($product['product_price'], 2),

View File

@ -105,11 +105,26 @@ class RetailcrmCatalog
} else {
$size = null;
}
$productForCombination = new Product($product['id_product']);
$offers = Product::getProductAttributesIds($product['id_product']);
if(!empty($offers)) {
foreach($offers as $offer) {
$combinations = $productForCombination->getAttributeCombinationsById($offer['id_product_attribute' ], $id_lang);
if (!empty($combinations)) {
foreach ($combinations as $combination) {
$arSet = array(
'group_name' => $combination['group_name'],
'attribute' => $combination['attribute_name'],
);
$arComb[] = $arSet;
}
}
$pictures = array();
$covers = Image::getImages($id_lang, $product['id_product'], $offer['id_product_attribute']);
foreach($covers as $cover) {
@ -144,6 +159,12 @@ class RetailcrmCatalog
'size' => $size
);
if (!empty($combinations)) {
foreach ($arComb as $itemComb) {
$item[mb_strtolower($itemComb['group_name'])] = htmlspecialchars($itemComb['attribute']);
}
}
$items[] = $item;
}
} else {

View File

@ -351,15 +351,33 @@ class RetailCRM extends Module
$productId = $item['id_product'];
}
if ($item['attributes']) {
$arProp = array();
$count = 0;
$arAttr = explode(",", $item['attributes']);
foreach ($arAttr as $valAttr) {
$arItem = explode(":", $valAttr);
$arProp[$count]['name'] = trim($arItem[0]);
$arProp[$count]['value'] = trim($arItem[1]);
$count++;
}
}
$order['items'][] = array(
'initialPrice' => !empty($item['rate'])
? $item['price'] + ($item['price'] * $item['rate'] / 100)
: $item['price']
,
'quantity' => $item['quantity'],
'productId' => $productId,
'productName' => $item['name']
'offer' => array('externalId' => $productId),
'productName' => $item['name'],
'properties' => $arProp
);
unset($arAttr);
unset($count);
unset($arProp);
}
$deliveryCode = $params['order']->id_carrier;