mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-03 19:53:19 +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) {
|
foreach($products as $product) {
|
||||||
$item = array(
|
$item = array(
|
||||||
'productId' => $product['product_id'],
|
//'productId' => $product['product_id'],
|
||||||
|
'offer' => array('externalId' => $product['product_id']),
|
||||||
'productName' => $product['product_name'],
|
'productName' => $product['product_name'],
|
||||||
'quantity' => $product['product_quantity'],
|
'quantity' => $product['product_quantity'],
|
||||||
'initialPrice' => round($product['product_price'], 2),
|
'initialPrice' => round($product['product_price'], 2),
|
||||||
|
@ -106,10 +106,25 @@ class RetailcrmCatalog
|
|||||||
$size = null;
|
$size = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$productForCombination = new Product($product['id_product']);
|
||||||
|
|
||||||
$offers = Product::getProductAttributesIds($product['id_product']);
|
$offers = Product::getProductAttributesIds($product['id_product']);
|
||||||
|
|
||||||
if(!empty($offers)) {
|
if(!empty($offers)) {
|
||||||
foreach($offers as $offer) {
|
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();
|
$pictures = array();
|
||||||
$covers = Image::getImages($id_lang, $product['id_product'], $offer['id_product_attribute']);
|
$covers = Image::getImages($id_lang, $product['id_product'], $offer['id_product_attribute']);
|
||||||
foreach($covers as $cover) {
|
foreach($covers as $cover) {
|
||||||
@ -144,6 +159,12 @@ class RetailcrmCatalog
|
|||||||
'size' => $size
|
'size' => $size
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!empty($combinations)) {
|
||||||
|
foreach ($arComb as $itemComb) {
|
||||||
|
$item[mb_strtolower($itemComb['group_name'])] = htmlspecialchars($itemComb['attribute']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -351,15 +351,33 @@ class RetailCRM extends Module
|
|||||||
$productId = $item['id_product'];
|
$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(
|
$order['items'][] = array(
|
||||||
'initialPrice' => !empty($item['rate'])
|
'initialPrice' => !empty($item['rate'])
|
||||||
? $item['price'] + ($item['price'] * $item['rate'] / 100)
|
? $item['price'] + ($item['price'] * $item['rate'] / 100)
|
||||||
: $item['price']
|
: $item['price']
|
||||||
,
|
,
|
||||||
'quantity' => $item['quantity'],
|
'quantity' => $item['quantity'],
|
||||||
'productId' => $productId,
|
'offer' => array('externalId' => $productId),
|
||||||
'productName' => $item['name']
|
'productName' => $item['name'],
|
||||||
|
'properties' => $arProp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
unset($arAttr);
|
||||||
|
unset($count);
|
||||||
|
unset($arProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
$deliveryCode = $params['order']->id_carrier;
|
$deliveryCode = $params['order']->id_carrier;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user