mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-02 19:33:14 +03:00
fix create orders (#7)
* [productId] replace to [offer][externalId] * properties for items in order and in icml
This commit is contained in:
parent
b61379cabc
commit
6eed3ad0e7
@ -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),
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user