correct generate icml (#16)

This commit is contained in:
DmitryZagorulko 2017-08-09 12:03:12 +03:00 committed by Alex Lushpai
parent 9bbe23195c
commit ee33a5fb40
4 changed files with 35 additions and 23 deletions

View File

@ -32,7 +32,7 @@ foreach ($customerRecords as $record) {
$customers[$record['id_customer']] = array(
'externalId' => $record['id_customer'],
'firstName' => $record['firstname'],
'lastname' => $record['lastname'],
'lastName' => $record['lastname'],
'email' => $record['email']
);
}

View File

@ -26,7 +26,7 @@ class RetailcrmCatalog
$currencies = Currency::getCurrencies();
$types = Category::getCategories($id_lang, true, false);
$types = Category::getCategories($id_lang, false, false);
foreach ($types AS $category) {
$categories[] = array(
'id' => $category['id_category'],
@ -106,9 +106,9 @@ class RetailcrmCatalog
} else {
$size = null;
}
$productForCombination = new Product($product['id_product']);
$productForCombination = new Product($product['id_product']);
$offers = Product::getProductAttributesIds($product['id_product']);
if(!empty($offers)) {
@ -116,7 +116,7 @@ class RetailcrmCatalog
$combinations = $productForCombination->getAttributeCombinationsById($offer['id_product_attribute' ], $id_lang);
if (!empty($combinations)) {
foreach ($combinations as $combination) {
$arSet = array(
'group_name' => $combination['group_name'],
@ -126,6 +126,11 @@ class RetailcrmCatalog
}
}
if (!empty($combinations[0]['reference'])) {
$articleCombination = $combinations[0]['reference'];
} else {
$articleCombination = null;
}
$pictures = array();
$covers = Image::getImages($id_lang, $product['id_product'], $offer['id_product_attribute']);
foreach($covers as $cover) {
@ -140,7 +145,8 @@ class RetailcrmCatalog
}
$offerPrice = Combination::getPrice($offer['id_product_attribute']);
$offerPrice = $offerPrice > 0 ? $offerPrice : $price;
//$offerPrice = $offerPrice > 0 ? $offerPrice : $price;
$offerPrice = $offerPrice != 0 ? $offerPrice + $price : $price;
$item = array(
'id' => $product['id_product'] . '#' . $offer['id_product_attribute'],
@ -155,9 +161,12 @@ class RetailcrmCatalog
'purchasePrice' => $purchasePrice,
'price' => round($offerPrice, 2),
'vendor' => $vendor,
'article' => $article,
'article' => ($articleCombination) ? $articleCombination : $article,
'weight' => $weight,
'size' => $size
'size' => $size,
'width' => $width,
'height' => $height,
'depth' => $depth
);
if (!empty($combinations)) {
@ -165,7 +174,7 @@ class RetailcrmCatalog
$item[mb_strtolower($itemComb['group_name'])] = htmlspecialchars($itemComb['attribute']);
}
}
$items[] = $item;
}
} else {
@ -197,7 +206,10 @@ class RetailcrmCatalog
'vendor' => $vendor,
'article' => $article,
'weight' => $weight,
'size' => $size
'size' => $size,
'width' => $width,
'height' => $height,
'depth' => $depth
);
$items[] = $item;

View File

@ -33,7 +33,10 @@ class RetailcrmIcml
'color' => 'Цвет',
'weight' => 'Вес',
'size' => 'Размер',
'tax' => 'Наценка'
'tax' => 'Наценка',
'width' => 'Ширина',
'height' => 'Высота',
'depth' => 'Глубина'
);
}
@ -75,14 +78,14 @@ class RetailcrmIcml
foreach ($categories as $category) {
$e = $this->eCategories->appendChild(
$this->dd->createElement(
'category', $category['name']
'category', htmlspecialchars($category['name'])
)
);
$e->setAttribute('id', $category['id']);
if ($category['parentId'] > 0) {
$e->setAttribute('parentId', $category['parentId']);
$e->setAttribute('parentId', htmlspecialchars($category['parentId']));
}
}
}

View File

@ -20,8 +20,7 @@ class RetailCRM extends Module
{
$this->name = 'retailcrm';
$this->tab = 'export';
$this->version = '2.1.1';
$this->version = '2.1';
$this->version = '2.2';
$this->author = 'Retail Driver LCC';
$this->displayName = $this->l('RetailCRM');
$this->description = $this->l('Integration module for RetailCRM');
@ -346,7 +345,7 @@ class RetailCRM extends Module
$orderdb = new Order($params['order']->id);
foreach ($orderdb->getProducts() as $item) {
if(isset($item['product_attribute_id']) && $item['product_attribute_id'] > 0) {
if (isset($item['product_attribute_id']) && $item['product_attribute_id'] > 0) {
$productId = $item['product_id'] . '#' . $item['product_attribute_id'];
} else {
$productId = $item['product_id'];
@ -425,7 +424,7 @@ class RetailCRM extends Module
}
foreach ($cart->getProducts() as $item) {
if(isset($item['id_product_attribute']) && $item['id_product_attribute'] > 0) {
if (isset($item['id_product_attribute']) && $item['id_product_attribute'] > 0) {
$productId = $item['id_product'] . '#' . $item['id_product_attribute'];
} else {
$productId = $item['id_product'];
@ -454,9 +453,7 @@ class RetailCRM extends Module
'properties' => $arProp
);
unset($arAttr);
unset($count);
unset($arProp);
unset($arAttr, $count, $arProp);
}
$deliveryCode = $params['order']->id_carrier;
@ -492,7 +489,7 @@ class RetailCRM extends Module
$order['customer']['externalId'] = $customer['externalId'];
$this->api->ordersCreate($order);
} elseif (isset($params['newOrderStatus'])){
} elseif (isset($params['newOrderStatus'])) {
$statusCode = $params['newOrderStatus']->id;
@ -514,7 +511,7 @@ class RetailCRM extends Module
}
private function validateCrmAddress($address) {
if(preg_match("/https:\/\/(.*).retailcrm.ru/", $address) === 1)
if (preg_match("/https:\/\/(.*).retailcrm.ru/", $address) === 1)
return true;
return false;