diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88251cc9..9784a1c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 2018-10-04 v.2.3.11
+* Добавлен учет настроек часового пояса при создании заказа
+* Устранено удаление событий изменения оплат при переводе выгрузки на агент
+* Добавлена возможность указать свойство в настройках экспорта, из которого будет подставляться картинка, если отсутствует в "Подробно" и "Анонс"
+* Добавлена подстановка домена в ссылках каталога в зависимости от пренадлежности инфоблока к сайту
+
## 2018-09-26 v.2.3.10
* Исправлена некорректная генерация скрипта UA
* Исправлена выгрузка остатков, если для товара указано более 50 складов
diff --git a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php
index 790c3f8f..d55f3b89 100644
--- a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php
+++ b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php
@@ -10,6 +10,7 @@ class RetailCrmICML
public $iblocks;
public $filename;
public $serverName;
+ public $defaultServerName;
public $propertiesSKU;
public $propertiesUnitSKU;
public $propertiesProduct;
@@ -20,6 +21,8 @@ class RetailCrmICML
public $encoding = 'utf-8';
public $encodingDefault = 'utf-8';
public $loadPurchasePrice = false;
+ public $productPictures;
+ public $skuPictures;
protected $fp;
protected $mainSection = 1000000;
@@ -136,7 +139,7 @@ class RetailCrmICML
$newText = $this->application->ConvertCharset($text, $this->encodingDefault, $this->encoding);
$newText = strip_tags($newText);
$newText = str_replace("&", "&", $newText);
-
+
return $newText;
}
@@ -245,7 +248,6 @@ class RetailCrmICML
protected function BuildOffers(&$allCategories)
{
-
$basePriceId = COption::GetOptionString(
$this->MODULE_ID,
$this->CRM_CATALOG_BASE_PRICE . (is_null($this->profileID) === false ? '_' . $this->profileID : ''),
@@ -253,7 +255,16 @@ class RetailCrmICML
);
foreach ($this->iblocks as $key => $id) {
+ $site = CAllIBlock::GetSite($id)->Fetch();
+
+ if ($site['SERVER_NAME']) {
+ $this->serverName = $site['SERVER_NAME'];
+ } else {
+ $this->serverName = $this->defaultServerName;
+ }
+
$barcodes = array();
+
$dbBarCode = CCatalogStoreBarCode::getList(
array(),
array("IBLOCK_ID" => $id),
@@ -270,8 +281,8 @@ class RetailCrmICML
$highloadblockSkuProps = array();
$highloadblockProductProps = array();
-
$productProps = CIBlockproperty::GetList(array(), array("IBLOCK_ID" => $id));
+
while ($arrProductProps = $productProps->Fetch()) {
if ($arrProductProps["USER_TYPE"] == 'directory') {
@@ -282,10 +293,9 @@ class RetailCrmICML
// Get Info by infoblocks
$iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch();
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id);
-
$skuProps = CIBlockproperty::GetList(array(), array("IBLOCK_ID" => $iblockOffer['IBLOCK_ID']));
- while ($arrSkuProps = $skuProps->Fetch()) {
+ while ($arrSkuProps = $skuProps->Fetch()) {
if ($arrSkuProps["USER_TYPE"] == 'directory') {
$highloadblockSkuProps[$arrSkuProps['CODE']] = $arrSkuProps;
}
@@ -306,19 +316,26 @@ class RetailCrmICML
// Set selected properties
foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
if ($this->propertiesProduct[$id][$key] != "") {
- $arSelect[] = "PROPERTY_" . $propProduct;
- $arSelect[] = "PROPERTY_" . $propProduct . ".NAME";
+ $arSelect[] = "PROPERTY_" . $propProduct;
+ $arSelect[] = "PROPERTY_" . $propProduct . ".NAME";
}
}
+ if ($this->productPictures && isset($this->productPictures[$id])) {
+ $arSelect[] = "PROPERTY_" . $this->productPictures[$id]['picture'];
+ $arSelect[] = "PROPERTY_" . $this->productPictures[$id]['picture'] . ".NAME";
+ }
+
$arSelectOffer = array(
'ID',
"NAME",
"DETAIL_PAGE_URL",
"DETAIL_PICTURE",
+ "PREVIEW_PICTURE",
'PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'],
"CATALOG_GROUP_" . $basePriceId
);
+
// Set selected properties
foreach ($this->propertiesSKU[$id] as $key => $propSKU) {
if ($this->propertiesSKU[$id][$key] != "") {
@@ -327,6 +344,11 @@ class RetailCrmICML
}
}
+ if ($this->skuPictures && isset($this->skuPictures[$id])) {
+ $arSelectOffer[] = "PROPERTY_" . $this->skuPictures[$id]['picture'];
+ $arSelectOffer[] = "PROPERTY_" . $this->skuPictures[$id]['picture'] . ".NAME";
+ }
+
// Set filter
$filter = array(
"IBLOCK_ID" => $id
@@ -352,40 +374,16 @@ class RetailCrmICML
$dbResProducts = CIBlockElement::GetList($order, $arfilter, false, false, $arSelect);
- $pictures = array();
$products = array();
+
while ($product = $dbResProducts->GetNext()) {
// Compile products to array
$products[$product['ID']] = $product;
$products[$product['ID']]['offers'] = array();
- $detailPicture = intval($product["DETAIL_PICTURE"]);
- $previewPicture = intval($product["PREVIEW_PICTURE"]);
-
- if ($detailPicture > 0 || $previewPicture > 0) {
- $picture = $detailPicture;
- if ($picture <= 0) {
- $picture = $previewPicture;
- }
- // Link pictureID and productID
- $pictures[$picture] = $product['ID'];
- }
}
+
unset($product);
- unset($detailPicture, $previewPicture, $picture);
-
- $pictureIDs = array_keys($pictures);
-
- // Get pathes of pictures
- $dbFiles = CFile::GetList(array(), array("@ID" => implode(',', $pictureIDs)));
- while ($file = $dbFiles->GetNext()) {
- // Link picture to product
- $products[$pictures[$file['ID']]]['PICTURE'] = $this->protocol .
- $this->serverName .
- '/upload/' . $file['SUBDIR'] .
- '/' . $file['FILE_NAME'] ;
- }
- unset($pictures);
if (!empty($iblockOffer['IBLOCK_ID'])) {
$arFilterOffer = array(
@@ -411,116 +409,140 @@ class RetailCrmICML
$stringOffers = "";
foreach ($products as $product) {
- // Get properties of product
- $resPropertiesProduct = Array();
- foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
- $resPropertiesProduct[$key] = "";
+ if (CFile::GetPath($product["DETAIL_PICTURE"])) {
+ $product['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($product["DETAIL_PICTURE"]);
+ } elseif (CFile::GetPath($product["PREVIEW_PICTURE"])){
+ $product['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($product["PREVIEW_PICTURE"]);
+ } elseif (
+ $this->productPictures
+ && isset($this->productPictures[$id])
+ && CFile::GetPath($product["PROPERTY_" . $this->productPictures[$id]['picture'] . "_VALUE"])
+ ) {
+ $picture = CFile::GetPath($product["PROPERTY_" . $this->productPictures[$id]['picture'] . "_VALUE"]);
+ $product['PICTURE'] = $this->protocol . $this->serverName . $picture;
+ }
- if ($propProduct != "") {
- if (isset($product["PROPERTY_" . $propProduct . "_NAME"])) {
- $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_NAME"];
- } elseif (isset($product["PROPERTY_" . $propProduct . "_VALUE"])) {
- $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"];
- } elseif (isset($product[$propProduct])) {
- $resPropertiesProduct[$key] = $product[$propProduct];
- }
- if (array_key_exists($key, $this->propertiesUnitProduct[$id])) {
- $resPropertiesProduct[$key] *= $this->measurement[$this->propertiesUnitProduct[$id][$key]];
- $resPropertiesProduct[$key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitProduct[$id][$key]];
- }
- if (isset($highloadblockProductProps[$propProduct])) {
- $propVal = $this->getHBprop($highloadblockProductProps[$propProduct], $product["PROPERTY_" . $propProduct . "_VALUE"]);
- $tableName = $highloadblockProductProps[$propProduct]['USER_TYPE_SETTINGS']['TABLE_NAME'];
- $field = $this->highloadblockProductProperties[$tableName][$iblockOffer['IBLOCK_ID']][$key];
+ // Get properties of product
+ $resPropertiesProduct = Array();
+ foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
+ $resPropertiesProduct[$key] = "";
- $resPropertiesProduct[$key] = $propVal[$field];
- }
+ if ($propProduct != "") {
+ if (isset($product["PROPERTY_" . $propProduct . "_NAME"])) {
+ $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_NAME"];
+ } elseif (isset($product["PROPERTY_" . $propProduct . "_VALUE"])) {
+ $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"];
+ } elseif (isset($product[$propProduct])) {
+ $resPropertiesProduct[$key] = $product[$propProduct];
+ }
+
+ if (array_key_exists($key, $this->propertiesUnitProduct[$id])) {
+ $resPropertiesProduct[$key] *= $this->measurement[$this->propertiesUnitProduct[$id][$key]];
+ $resPropertiesProduct[$key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitProduct[$id][$key]];
+ }
+
+ if (isset($highloadblockProductProps[$propProduct])) {
+ $propVal = $this->getHBprop($highloadblockProductProps[$propProduct], $product["PROPERTY_" . $propProduct . "_VALUE"]);
+ $tableName = $highloadblockProductProps[$propProduct]['USER_TYPE_SETTINGS']['TABLE_NAME'];
+ $field = $this->highloadblockProductProperties[$tableName][$id][$key];
+
+ $resPropertiesProduct[$key] = $propVal[$field];
}
}
+ }
- // Get categories of product
- $categories = array();
- $dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true);
- while ($arResCategory = $dbResCategories->Fetch()) {
- $categories[$arResCategory["ID"]] = array(
- 'ID' => $arResCategory["ID"],
- 'NAME' => $arResCategory["NAME"],
- );
- }
- if (count($categories) == 0) {
- $catId = $this->mainSection + $id;
- $categories[$catId] = $allCategories[$catId];
- }
+ // Get categories of product
+ $categories = array();
+ $dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true);
+ while ($arResCategory = $dbResCategories->Fetch()) {
+ $categories[$arResCategory["ID"]] = array(
+ 'ID' => $arResCategory["ID"],
+ 'NAME' => $arResCategory["NAME"],
+ );
+ }
+ if (count($categories) == 0) {
+ $catId = $this->mainSection + $id;
+ $categories[$catId] = $allCategories[$catId];
+ }
- $existOffer = false;
- if (!empty($iblockOffer['IBLOCK_ID'])) {
- foreach ($product['offers'] as $offer) {
- $offer['BARCODE'] = isset($barcodes[$offer['ID']]) ? $barcodes[$offer['ID']] : '';
- $offer['PRODUCT_ID'] = $product["ID"];
- $offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
+ $existOffer = false;
+ if (!empty($iblockOffer['IBLOCK_ID'])) {
+ foreach ($product['offers'] as $offer) {
+ $offer['BARCODE'] = isset($barcodes[$offer['ID']]) ? $barcodes[$offer['ID']] : '';
+ $offer['PRODUCT_ID'] = $product["ID"];
+ $offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
- if (CFile::GetPath($offer["DETAIL_PICTURE"])) {
- $offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["DETAIL_PICTURE"]);
- } else {
- $offer['PICTURE'] = $product["PICTURE"];
- }
-
- $offer['PRODUCT_NAME'] = $product["NAME"];
- $offer['PRODUCT_ACTIVE'] = $product["ACTIVE"];
- $offer['PRICE'] = $offer['CATALOG_PRICE_' . $basePriceId];
- $offer['PURCHASE_PRICE'] = $offer['CATALOG_PURCHASING_PRICE'];
- $offer['QUANTITY'] = $offer["CATALOG_QUANTITY"];
-
- // Get properties of product
- foreach ($this->propertiesSKU[$id] as $key => $propSKU) {
- if ($propSKU != "") {
- if (isset ($offer["PROPERTY_" . $propSKU . "_NAME"])) {
- $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_NAME"];
- } elseif (isset($offer["PROPERTY_" . $propSKU . "_VALUE"])) {
- $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_VALUE"];
- } elseif (isset($offer[$propSKU])) {
- $offer['_PROP_' . $key] = $offer[$propSKU];
- }
- if (array_key_exists($key, $this->propertiesUnitSKU[$id])) {
- $offer['_PROP_' . $key] *= $this->measurement[$this->propertiesUnitSKU[$id][$key]];
- $offer['_PROP_' . $key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitSKU[$id][$key]];
- }
- if (isset($highloadblockSkuProps[$propSKU])) {
- $propVal = $this->getHBprop($highloadblockSkuProps[$propSKU], $offer["PROPERTY_" . $propSKU . "_VALUE"]);
- $tableName = $highloadblockSkuProps[$propSKU]['USER_TYPE_SETTINGS']['TABLE_NAME'];
- $field = $this->highloadblockSkuProperties[$tableName][$id][$key];
- $offer['_PROP_' . $key] = $propVal[$field];
- }
- }
- }
-
- foreach ($resPropertiesProduct as $key => $propProduct) {
- if ($this->propertiesProduct[$id][$key] != "" && !isset($offer[$key])) {
- $offer['_PROP_' . $key] = $propProduct;
- }
- }
-
- $stringOffers .= $this->BuildOffer($offer, $categories, $iblock, $allCategories);
- $existOffer = true;
+ if (CFile::GetPath($offer["DETAIL_PICTURE"])) {
+ $offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["DETAIL_PICTURE"]);
+ } elseif (CFile::GetPath($offer["PREVIEW_PICTURE"])){
+ $offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["PREVIEW_PICTURE"]);
+ } elseif (
+ $this->skuPictures
+ && isset($this->skuPictures[$id])
+ && CFile::GetPath($offer["PROPERTY_" . $this->skuPictures[$id]['picture'] . "_VALUE"])
+ ) {
+ $picture = CFile::GetPath($offer["PROPERTY_" . $this->skuPictures[$id]['picture'] . "_VALUE"]);
+ $offer['PICTURE'] = $this->protocol . $this->serverName . $picture;
+ } else {
+ $offer['PICTURE'] = $product['PICTURE'];
+ }
+
+ $offer['PRODUCT_NAME'] = $product["NAME"];
+ $offer['PRODUCT_ACTIVE'] = $product["ACTIVE"];
+ $offer['PRICE'] = $offer['CATALOG_PRICE_' . $basePriceId];
+ $offer['PURCHASE_PRICE'] = $offer['CATALOG_PURCHASING_PRICE'];
+ $offer['QUANTITY'] = $offer["CATALOG_QUANTITY"];
+
+ // Get properties of product
+ foreach ($this->propertiesSKU[$id] as $key => $propSKU) {
+ if ($propSKU != "") {
+ if (isset ($offer["PROPERTY_" . $propSKU . "_NAME"])) {
+ $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_NAME"];
+ } elseif (isset($offer["PROPERTY_" . $propSKU . "_VALUE"])) {
+ $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_VALUE"];
+ } elseif (isset($offer[$propSKU])) {
+ $offer['_PROP_' . $key] = $offer[$propSKU];
+ }
+ if (array_key_exists($key, $this->propertiesUnitSKU[$id])) {
+ $offer['_PROP_' . $key] *= $this->measurement[$this->propertiesUnitSKU[$id][$key]];
+ $offer['_PROP_' . $key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitSKU[$id][$key]];
+ }
+ if (isset($highloadblockSkuProps[$propSKU])) {
+ $propVal = $this->getHBprop($highloadblockSkuProps[$propSKU], $offer["PROPERTY_" . $propSKU . "_VALUE"]);
+ $tableName = $highloadblockSkuProps[$propSKU]['USER_TYPE_SETTINGS']['TABLE_NAME'];
+ $field = $this->highloadblockSkuProperties[$tableName][$id][$key];
+ $offer['_PROP_' . $key] = $propVal[$field];
+ }
+ }
}
- }
- if (!$existOffer) {
- $offer['BARCODE'] = isset($barcodes[$product["ID"]]) ? $barcodes[$product["ID"]] : '';
- $product['PRODUCT_ID'] = $product["ID"];
- $product['PRODUCT_NAME'] = $product["NAME"];
- $product['PRODUCT_ACTIVE'] = $product["ACTIVE"];
- $product['PRICE'] = $product['CATALOG_PRICE_' . $basePriceId];
- $product['PURCHASE_PRICE'] = $product['CATALOG_PURCHASING_PRICE'];
- $product['QUANTITY'] = $product["CATALOG_QUANTITY"];
foreach ($resPropertiesProduct as $key => $propProduct) {
- if ($this->propertiesProduct[$id][$key] != "" || $this->propertiesProduct[$id][str_replace("_UNIT", "", $key)] != "") {
- $product['_PROP_' . $key] = $propProduct;
+ if ($this->propertiesProduct[$id][$key] != "" && !isset($offer[$key])) {
+ $offer['_PROP_' . $key] = $propProduct;
}
}
- $stringOffers .= $this->BuildOffer($product, $categories, $iblock, $allCategories);
+ $stringOffers .= $this->BuildOffer($offer, $categories, $iblock, $allCategories);
+ $existOffer = true;
}
+ }
+ if (!$existOffer) {
+ $offer['BARCODE'] = isset($barcodes[$product["ID"]]) ? $barcodes[$product["ID"]] : '';
+ $product['PRODUCT_ID'] = $product["ID"];
+ $product['PRODUCT_NAME'] = $product["NAME"];
+ $product['PRODUCT_ACTIVE'] = $product["ACTIVE"];
+ $product['PRICE'] = $product['CATALOG_PRICE_' . $basePriceId];
+ $product['PURCHASE_PRICE'] = $product['CATALOG_PURCHASING_PRICE'];
+ $product['QUANTITY'] = $product["CATALOG_QUANTITY"];
+
+ foreach ($resPropertiesProduct as $key => $propProduct) {
+ if ($this->propertiesProduct[$id][$key] != "" || $this->propertiesProduct[$id][str_replace("_UNIT", "", $key)] != "") {
+ $product['_PROP_' . $key] = $propProduct;
+ }
+ }
+
+ $stringOffers .= $this->BuildOffer($product, $categories, $iblock, $allCategories);
+ }
}
unset($products);
@@ -568,7 +590,10 @@ class RetailCrmICML
$arOffer['DETAIL_PAGE_URL'] = str_replace("#SECTION_PATH#", $path, $arOffer['DETAIL_PAGE_URL']);
}
- $offer .= "\n";
+ if (isset($arOffer["PICTURE"]) && $arOffer["PICTURE"]) {
+ $offer .= "\n";
+ }
+
$offer .= "" . $this->protocol . $this->serverName . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "\n";
$offer .= "" . $this->PrepareValue($arOffer['PRICE']) . "\n";
@@ -615,7 +640,7 @@ class RetailCrmICML
}
$offer.= "\n";
-
+
return $offer;
}
diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php
index b7c176c4..3f14a7be 100644
--- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php
+++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php
@@ -47,7 +47,7 @@ class RetailCrmOrder
$order = array(
'number' => $arFields['NUMBER'],
'externalId' => $arFields['ID'],
- 'createdAt' => new \DateTime($arFields['DATE_INSERT']),
+ 'createdAt' => $arFields['DATE_INSERT'],
'customer' => array('externalId' => $arFields['USER_ID']),
'paymentType' => isset($arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]]) ?
$arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]] : '',
@@ -92,7 +92,7 @@ class RetailCrmOrder
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$countrys = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
- $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
+ $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
foreach ($countrysFile->country as $country) {
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
}
@@ -153,7 +153,7 @@ class RetailCrmOrder
$order = $newResOrder;
} elseif ($newResOrder === false) {
RCrmActions::eventLog('RetailCrmOrder::orderSend', 'retailCrmBeforeOrderSend()', 'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend');
-
+
return false;
}
}
@@ -172,7 +172,7 @@ class RetailCrmOrder
return $order;
}
-
+
/**
* Mass order uploading, without repeating; always returns true, but writes error log
* @param $pSize
@@ -224,7 +224,7 @@ class RetailCrmOrder
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
- $optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
+ $optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
@@ -258,19 +258,19 @@ class RetailCrmOrder
}
$order = self::orderObjToArr($id);
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
-
+
$site = count($optionsSitesList) > 1 ? $optionsSitesList[$order['LID']] : null;
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
- $arOrders = self::orderSend($order, $api, $arParams, false, $site);
+ $arOrders = self::orderSend($order, $api, $arParams, false, $site);
if (!$arCustomers || !$arOrders) {
continue;
}
-
+
$resCustomers[$order['LID']][] = $arCustomers;
- $resOrders[$order['LID']][] = $arOrders;
-
+ $resOrders[$order['LID']][] = $arOrders;
+
$recOrders[] = $orderId;
}
@@ -321,11 +321,12 @@ class RetailCrmOrder
public static function orderObjToArr($obOrder)
{
+ $culture = new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"));
$arOrder = array(
'ID' => $obOrder->getId(),
'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'),
'LID' => $obOrder->getSiteId(),
- 'DATE_INSERT' => $obOrder->getDateInsert()->toString(new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"))),
+ 'DATE_INSERT' => $obOrder->getDateInsert()->toString($culture),
'STATUS_ID' => $obOrder->getField('STATUS_ID'),
'USER_ID' => $obOrder->getUserId(),
'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(),
@@ -341,7 +342,7 @@ class RetailCrmOrder
'COMMENTS' => $obOrder->getField('COMMENTS'),
'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED'),
);
-
+
$shipmentList = $obOrder->getShipmentCollection();
foreach ($shipmentList as $shipmentData) {
if ($shipmentData->isSystem()) {
@@ -370,7 +371,7 @@ class RetailCrmOrder
foreach ($basketItems as $item) {
$arOrder['BASKET'][] = $item->getFields();
}
-
+
return $arOrder;
}
}
diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php
index b4f7d1a1..ab1ff81b 100644
--- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php
+++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php
@@ -36,7 +36,7 @@ class RetailCrmOrder
* @return array - array('order' = $order, 'customer' => $customer)
*/
public static function orderSend($arFields, $api, $arParams, $send = false, $site = null, $methodApi = 'ordersEdit')
- {
+ {
if (!$api || empty($arParams)) { // add cond to check $arParams
return false;
}
@@ -50,7 +50,7 @@ class RetailCrmOrder
$order = array(
'number' => $arFields['NUMBER'],
'externalId' => $arFields['ID'],
- 'createdAt' => new \DateTime($arFields['DATE_INSERT']),
+ 'createdAt' => $arFields['DATE_INSERT'],
'customer' => array('externalId' => $arFields['USER_ID']),
'orderType' => isset($arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']]) ?
$arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '',
@@ -96,7 +96,7 @@ class RetailCrmOrder
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$countrys = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
- $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
+ $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
foreach ($countrysFile->country as $country) {
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
}
@@ -202,22 +202,30 @@ class RetailCrmOrder
}
$payments[] = $pm;
} else {
- RCrmActions::eventLog('RetailCrmOrder::orderSend', 'payments', 'OrderID = ' . $arFields['ID'] . '. Payment not found.');
-
+ RCrmActions::eventLog(
+ 'RetailCrmOrder::orderSend',
+ 'payments',
+ 'OrderID = ' . $arFields['ID'] . '. Payment not found.'
+ );
+
continue;
}
}
if (count($payments) > 0) {
$order['payments'] = $payments;
}
-
+
//send
if (function_exists('retailCrmBeforeOrderSend')) {
$newResOrder = retailCrmBeforeOrderSend($order, $arFields);
if (is_array($newResOrder) && !empty($newResOrder)) {
$order = $newResOrder;
} elseif ($newResOrder === false) {
- RCrmActions::eventLog('RetailCrmOrder::orderSend', 'retailCrmBeforeOrderSend()', 'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend');
+ RCrmActions::eventLog(
+ 'RetailCrmOrder::orderSend',
+ 'retailCrmBeforeOrderSend()',
+ 'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend'
+ );
return false;
}
@@ -237,7 +245,7 @@ class RetailCrmOrder
return $order;
}
-
+
/**
* Mass order uploading, without repeating; always returns true, but writes error log
* @param $pSize
@@ -289,7 +297,7 @@ class RetailCrmOrder
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
- $optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
+ $optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
@@ -325,18 +333,18 @@ class RetailCrmOrder
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
- $arOrders = self::orderSend($order, $api, $arParams, false, $site);
+ $arOrders = self::orderSend($order, $api, $arParams, false, $site);
if (!$arCustomers || !$arOrders) {
continue;
}
-
+
$resCustomers[$order['LID']][] = $arCustomers;
- $resOrders[$order['LID']][] = $arOrders;
-
+ $resOrders[$order['LID']][] = $arOrders;
+
$recOrders[] = $orderId;
}
-
+
if (count($resOrders) > 0) {
foreach ($resCustomers as $key => $customerLoad) {
if ($optionsSitesList) {
@@ -384,11 +392,12 @@ class RetailCrmOrder
public static function orderObjToArr($obOrder)
{
+ $culture = new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"));
$arOrder = array(
'ID' => $obOrder->getId(),
'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'),
'LID' => $obOrder->getSiteId(),
- 'DATE_INSERT' => $obOrder->getDateInsert()->toString(new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"))),
+ 'DATE_INSERT' => $obOrder->getDateInsert()->toString($culture),
'STATUS_ID' => $obOrder->getField('STATUS_ID'),
'USER_ID' => $obOrder->getUserId(),
'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(),
diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru
index 1d0ed1dd..e1b7a362 100644
--- a/intaro.retailcrm/description.ru
+++ b/intaro.retailcrm/description.ru
@@ -1,3 +1,4 @@
-- Исправлена некорректная генерация скрипта UA
-- Улучшена выгрузка остатков по складам в retailCRM
-- Улучшена обработка истории изменений заказов
+- Добавлен учет настроек часового пояса при создании заказа
+- Устранено удаление событий изменения оплат при переводе выгрузки на агент
+- Добавлена возможность указать свойство в настройках экспорта, из которого будет подставляться картинка, если отсутствует в "Подробно" и "Анонс"
+- Добавлена подстановка домена в ссылках каталога в зависимости от пренадлежности инфоблока к сайту
\ No newline at end of file
diff --git a/intaro.retailcrm/export/export_run.php b/intaro.retailcrm/export/export_run.php
index e6d540a7..a6f25e73 100644
--- a/intaro.retailcrm/export/export_run.php
+++ b/intaro.retailcrm/export/export_run.php
@@ -15,7 +15,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
if (!CModule::IncludeModule("intaro.retailcrm")){
return;
}
-
+
$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
while ($ar = $rsSites->Fetch()) {
if ($ar['DEF'] == 'Y') {
@@ -113,6 +113,22 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
}
}
+ $productPictures = array();
+
+ if (is_array($IBLOCK_PROPERTY_PRODUCT_picture)) {
+ foreach ($IBLOCK_PROPERTY_PRODUCT_picture as $key => $value) {
+ $productPictures[$key]['picture'] = $value;
+ }
+ }
+
+ $skuPictures = array();
+
+ if (is_array($IBLOCK_PROPERTY_SKU_picture)) {
+ foreach ($IBLOCK_PROPERTY_SKU_picture as $key => $value) {
+ $skuPictures[$key]['picture'] = $value;
+ }
+ }
+
$loader = new RetailCrmICML();
$loader->profileID = $PROFILE_ID;
$loader->iblocks = $IBLOCK_EXPORT;
@@ -120,6 +136,8 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
$loader->propertiesUnitSKU = $IBLOCK_PROPERTY_UNIT_SKU;
$loader->propertiesProduct = $IBLOCK_PROPERTY_PRODUCT;
$loader->propertiesUnitProduct = $IBLOCK_PROPERTY_UNIT_PRODUCT;
+ $loader->productPictures = $productPictures;
+ $loader->skuPictures = $skuPictures;
if ($hlblockModule === true) {
$loader->highloadblockSkuProperties = $IBLOCK_PROPERTY_SKU_HIGHLOADBLOCK;
@@ -127,7 +145,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
}
$loader->filename = $SETUP_FILE_NAME;
- $loader->serverName = $SERVER_NAME;
+ $loader->defaultServerName = $SERVER_NAME;
$loader->application = $APPLICATION;
$loader->loadPurchasePrice = $LOAD_PURCHASE_PRICE == 'Y';
$loader->Load();
diff --git a/intaro.retailcrm/export/export_setup.php b/intaro.retailcrm/export/export_setup.php
index 174354ce..67d73905 100644
--- a/intaro.retailcrm/export/export_setup.php
+++ b/intaro.retailcrm/export/export_setup.php
@@ -29,6 +29,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
"length" => "length",
"width" => "width",
"height" => "height",
+ "picture" => "picture"
);
if(!check_bitrix_sessid()) {
@@ -164,10 +165,10 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
"length" => GetMessage("PROPERTY_LENGTH_HEADER_NAME"),
"width" => GetMessage("PROPERTY_WIDTH_HEADER_NAME"),
"height" => GetMessage("PROPERTY_HEIGHT_HEADER_NAME"),
+ "picture" => GetMessage("PROPERTY_PICTURE_HEADER_NAME")
);
$iblockFieldsName = Array(
-
"weight" => Array("code" => "catalog_weight" , "name" => GetMessage("SELECT_WEIGHT_PROPERTY_NAME"), 'unit' => 'mass'),
"length" => Array("code" => "catalog_length" , "name" => GetMessage("SELECT_LENGTH_PROPERTY_NAME"), 'unit' => 'length'),
"width" => Array("code" => "catalog_width" , "name" => GetMessage("SELECT_WIDTH_PROPERTY_NAME"), 'unit' => 'length'),
@@ -183,6 +184,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
"length" => Array("LENGTH", "DLINA"),
"width" => Array("WIDTH", "SHIRINA"),
"height" => Array("HEIGHT", "VISOTA"),
+ "picture" => Array("PICTURE", "PICTURE")
);
$units = Array(
@@ -795,7 +797,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
$vals .= ",IBLOCK_PROPERTY_PRODUCT_" . $val;
$vals .= ",IBLOCK_PROPERTY_UNIT_PRODUCT_" . $val;
- if ($hlblockModule === true) {
+ if ($hlblockModule === true && $val != 'picture') {
foreach ($hlblockList as $hlblockTable => $hlblock) {
$vals .= ',highloadblock' . $hlblockTable . '_' . $val;
}
diff --git a/intaro.retailcrm/install/index.php b/intaro.retailcrm/install/index.php
index b8549258..50af5d2d 100644
--- a/intaro.retailcrm/install/index.php
+++ b/intaro.retailcrm/install/index.php
@@ -10,7 +10,7 @@ IncludeModuleLangFile(__FILE__);
if (class_exists('intaro_retailcrm'))
return;
-class intaro_retailcrm extends CModule
+class intaro_retailcrm extends CModule
{
var $MODULE_ID = 'intaro.retailcrm';
var $OLD_MODULE_ID = 'intaro.intarocrm';
@@ -19,10 +19,10 @@ class intaro_retailcrm extends CModule
var $MODULE_NAME;
var $MODULE_DESCRIPTION;
var $MODULE_GROUP_RIGHTS = 'N';
-
+
var $PARTNER_NAME;
var $PARTNER_URI;
-
+
var $RETAIL_CRM_API;
var $RETAIL_CRM_EXPORT = 'retailcrm';
var $CRM_API_HOST_OPTION = 'api_host';
@@ -59,16 +59,16 @@ class intaro_retailcrm extends CModule
var $CRM_PRICES = 'prices';
var $CRM_PRICE_SHOPS = 'price_shops';
var $CRM_IBLOCKS_PRICES = 'iblock_prices';
-
+
var $CRM_COLLECTOR = 'collector';
var $CRM_COLL_KEY = 'coll_key';
-
+
var $CRM_UA = 'ua';
var $CRM_UA_KEYS = 'ua_keys';
-
+
var $CRM_API_VERSION = 'api_version';
var $HISTORY_TIME = 'history_time';
-
+
var $INSTALL_PATH;
function intaro_retailcrm()
@@ -98,18 +98,18 @@ class intaro_retailcrm extends CModule
$APPLICATION->ThrowException(GetMessage("RETAILCRM_CURL_ERR"));
return false;
}
-
+
$infoSale = CModule::CreateModuleObject('sale')->MODULE_VERSION;
if (version_compare($infoSale, '16', '<=')) {
$APPLICATION->ThrowException(GetMessage("SALE_VERSION_ERR"));
-
+
return false;
}
if (!date_default_timezone_get()) {
if (!ini_get('date.timezone')) {
$APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR"));
-
+
return false;
}
}
@@ -124,7 +124,7 @@ class intaro_retailcrm extends CModule
include($this->INSTALL_PATH . '/../classes/general/Exception/CurlException.php');
include($this->INSTALL_PATH . '/../classes/general/RestNormalizer.php');
include($this->INSTALL_PATH . '/../classes/general/Logger.php');
-
+
$version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0);
if ($version == 'v4') {
include($this->INSTALL_PATH . '/../classes/general/ApiClient_v4.php');
@@ -139,7 +139,7 @@ class intaro_retailcrm extends CModule
$step = intval($_REQUEST['step']);
if (file_exists($this->INSTALL_PATH . '/../classes/general/config/options.xml')) {
- $options = simplexml_load_file($this->INSTALL_PATH . '/../classes/general/config/options.xml');
+ $options = simplexml_load_file($this->INSTALL_PATH . '/../classes/general/config/options.xml');
foreach ($options->contragents->contragent as $contragent) {
$type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET);
@@ -157,8 +157,8 @@ class intaro_retailcrm extends CModule
$arResult['orderProps'][] = $type;
} else {
$groups = explode(",", (string)$field["group"]);
- foreach ($groups as $group) {
- $type["GROUP"][] = trim($group);
+ foreach ($groups as $group) {
+ $type["GROUP"][] = trim($group);
}
$arResult['legalDetails'][] = $type;
}
@@ -184,14 +184,14 @@ class intaro_retailcrm extends CModule
if (!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG';
}
-
+
if ($api_host = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_API_HOST_OPTION, 0)) {
$arResult['API_HOST'] = $api_host;
}
if ($api_key = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_API_KEY_OPTION, 0)) {
$arResult['API_KEY'] = $api_key;
}
-
+
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
@@ -213,17 +213,17 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
-
+
return;
}
-
+
$api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
$api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
// form correct url
$api_host = parse_url($api_host);
if ($api_host['scheme'] != 'https') {
- $api_host['scheme'] = 'https';
+ $api_host['scheme'] = 'https';
}
$api_host = $api_host['scheme'] . '://' . $api_host['host'];
@@ -232,10 +232,10 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
-
+
return;
}
-
+
$ping = self::ping($api_host, $api_key);
if (isset($ping['sitesList'])) {
$arResult['sitesList'] = $ping['sitesList'];
@@ -244,13 +244,13 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
-
+
return;
}
-
+
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
-
+
if ($sites_list = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_SITES_LIST, 0)) {
$arResult['SITES_LIST'] = unserialize($sites_list);
}
@@ -273,14 +273,14 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
-
+
return;
}
-
+
$arResult['arSites'] = RCrmActions::SitesList();
-
+
if (count($arResult['arSites']) > 1) {
-
+
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
@@ -296,7 +296,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step11.php'
);
-
+
return;
}
@@ -318,10 +318,10 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
-
+
return;
}
-
+
$ping = self::ping($api_host, $api_key);
if (isset($ping['sitesList'])) {
$arResult['sitesList'] = $ping['sitesList'];
@@ -330,18 +330,18 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
-
+
return;
}
-
+
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize(array()));
}
-
+
//prepare crm lists
- try {
+ try {
$arResult['orderTypesList'] = $this->RETAIL_CRM_API->orderTypesList()->orderTypes;
$arResult['deliveryTypesList'] = $this->RETAIL_CRM_API->deliveryTypesList()->deliveryTypes;
$arResult['deliveryServicesList'] = $this->RETAIL_CRM_API->deliveryServicesList()->deliveryServices;
@@ -359,7 +359,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
-
+
return;
}
@@ -370,10 +370,10 @@ class intaro_retailcrm extends CModule
}
}
$arResult['deliveryTypesList'] = $delivTypes;
-
+
//bitrix personTypes
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
-
+
//bitrix deliveryList
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
@@ -382,7 +382,7 @@ class intaro_retailcrm extends CModule
//bitrix statusesList --statuses
$arResult['bitrixStatusesList'] = RCrmActions::StatusesList();
-
+
if ($order_types = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_TYPES_ARR, 0)) {
$arResult['ORDER_TYPES'] = array_flip(unserialize($order_types));
}
@@ -421,7 +421,7 @@ class intaro_retailcrm extends CModule
//bitrix orderTypesList
$arResult['arSites'] = RCrmActions::SitesList();
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
-
+
$orderTypesArr = array();
foreach ($arResult['bitrixOrderTypesList'] as $orderType) {
$orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']]));
@@ -429,7 +429,7 @@ class intaro_retailcrm extends CModule
//bitrix deliveryTypesList
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
-
+
if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'false') {
$deliveryTypesArr = array();
foreach ($arResult['bitrixDeliveryTypesList'] as $delivery) {
@@ -482,7 +482,7 @@ class intaro_retailcrm extends CModule
//bitrix paymentTypesList
$arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList();
-
+
$paymentTypesArr = array();
foreach ($arResult['bitrixPaymentTypesList'] as $payment) {
$paymentTypesArr[$payment['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $payment['ID']]));
@@ -490,7 +490,7 @@ class intaro_retailcrm extends CModule
//bitrix statusesList
$arResult['bitrixStatusesList'] = RCrmActions::StatusesList();
-
+
$paymentStatusesArr = array();
$canselOrderArr = array();
@@ -505,9 +505,9 @@ class intaro_retailcrm extends CModule
$paymentArr = array();
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
-
+
//new page
- //form orderProps
+ //form orderProps
$arResult['arProp'] = RCrmActions::OrderPropsList();
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr($orderTypesArr)));
@@ -519,7 +519,7 @@ class intaro_retailcrm extends CModule
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1);
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array()));
COption::SetOptionString($this->MODULE_ID, $this->CRM_CANSEL_ORDER, serialize(RCrmActions::clearArr($canselOrderArr)));
-
+
if ($orderProps = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_PROPS, 0)) {
$arResult['ORDER_PROPS'] = unserialize($orderProps);
}
@@ -532,7 +532,7 @@ class intaro_retailcrm extends CModule
if ($contragentType = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_CONTRAGENT_TYPE, 0)) {
$arResult['CONTRAGENT_TYPES'] = unserialize($contragentType);
}
-
+
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step3.php'
);
@@ -573,16 +573,16 @@ class intaro_retailcrm extends CModule
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
die(json_encode(array("finish" => $finish, "percent" => $percent)));
}
-
+
if (isset($_POST['back']) && $_POST['back']) {
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step2.php'
);
}
-
+
//bitrix orderTypesList
$orderTypesList = RCrmActions::OrderTypesList(RCrmActions::SitesList());
-
+
$orderTypesArr = array();
foreach ($orderTypesList as $orderType) {
$orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']]));
@@ -601,7 +601,7 @@ class intaro_retailcrm extends CModule
}
$orderPropsArr[$orderType['ID']] = $_orderPropsArr;
}
-
+
//legal details props
$legalDetailsArr = array();
foreach ($orderTypesList as $orderType) {
@@ -631,7 +631,7 @@ class intaro_retailcrm extends CModule
COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOM_FIELDS, serialize(RCrmActions::clearArr($customFieldsArr)));
COption::SetOptionString($this->MODULE_ID, $this->CRM_LEGAL_DETAILS, serialize(RCrmActions::clearArr($legalDetailsArr)));
COption::SetOptionString($this->MODULE_ID, $this->CRM_CONTRAGENT_TYPE, serialize(RCrmActions::clearArr($contragentTypeArr)));
-
+
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step4.php'
);
@@ -667,14 +667,14 @@ class intaro_retailcrm extends CModule
if (!CModule::IncludeModule("sale")) {
$arResult['errCode'] = 'ERR_SALE';
}
-
+
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$api = new \RetailCrm\ApiClient($api_host, $api_key);
-
+
$customerH = self::historyLoad($api, 'customersHistory');
COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY, $customerH);
-
+
//new data
if ($historyDate = COption::GetOptionString($this->OLD_MODULE_ID, 'order_history_date', 0)) {
try {
@@ -703,7 +703,7 @@ class intaro_retailcrm extends CModule
}
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY, $orderH);
-
+
if ($orderLastId = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_LAST_ID, 0)) {
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, $orderLastId);
} else {
@@ -719,7 +719,7 @@ class intaro_retailcrm extends CModule
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
}
}
-
+
if ($orderFailedIds = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_FAILED_IDS, 0)) {
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, $orderFailedIds);
}
@@ -752,7 +752,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
);
-
+
return;
}
@@ -796,11 +796,13 @@ class intaro_retailcrm extends CModule
"length" => "length",
"width" => "width",
"height" => "height",
+ "picture" => "picture",
);
-
+
$propertiesSKU = array();
$propertiesUnitSKU = array();
$propertiesHbSKU = array();
+
foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) {
$propertiesSKU[$iblock][$prop] = $val;
@@ -809,7 +811,7 @@ class intaro_retailcrm extends CModule
$propertiesUnitSKU[$iblock][$prop] = $val;
}
- if ($hlblockModule === true) {
+ if ($hlblockModule === true && $prop != 'picture') {
foreach ($hlblockList as $tableName => $hb) {
foreach ($_POST['highloadblock' . $tableName . '_' . $prop] as $iblock => $val) {
$propertiesHbSKU[$tableName][$iblock][$prop] = $val;
@@ -821,6 +823,7 @@ class intaro_retailcrm extends CModule
$propertiesProduct = array();
$propertiesUnitProduct = array();
$propertiesHbProduct = array();
+
foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) {
$propertiesProduct[$iblock][$prop] = $val;
@@ -829,7 +832,7 @@ class intaro_retailcrm extends CModule
$propertiesUnitProduct[$iblock][$prop] = $val;
}
- if ($hlblockModule === true) {
+ if ($hlblockModule === true && $prop != 'picture') {
foreach ($hlblockList as $tableName => $hb) {
foreach ($_POST['highloadblock_product' . $tableName . '_' . $prop] as $iblock => $val) {
$propertiesHbProduct[$tableName][$iblock][$prop] = $val;
@@ -891,7 +894,7 @@ class intaro_retailcrm extends CModule
RegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "paymentSave");
RegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $this->MODULE_ID, "RetailCrmEvent", "paymentDelete");
- COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types'])));
+ COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types'])));
COption::SetOptionString($this->MODULE_ID, $this->CRM_INVENTORIES_UPLOAD, 'N');
COption::SetOptionString($this->MODULE_ID, $this->CRM_PRICES_UPLOAD, 'N');
COption::SetOptionString($this->MODULE_ID, $this->CRM_COLLECTOR, 'N');
@@ -911,7 +914,7 @@ class intaro_retailcrm extends CModule
);
$this->CopyFiles();
- if (isset($_POST['LOAD_NOW'])) {
+ if (isset($_POST['LOAD_NOW'])) {
$loader = new RetailCrmICML();
$loader->iblocks = $iblocks;
$loader->propertiesUnitProduct = $propertiesUnitProduct;
@@ -927,8 +930,8 @@ class intaro_retailcrm extends CModule
$loader->filename = $filename;
$loader->serverName = \Bitrix\Main\Context::getCurrent()->getServer()->getHttpHost();
$loader->application = $APPLICATION;
- $loader->Load();
- }
+ $loader->Load();
+ }
if ($typeLoading == 'agent' || $typeLoading == 'cron') {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->RETAIL_CRM_EXPORT . '_run.php')) {
@@ -965,7 +968,7 @@ class intaro_retailcrm extends CModule
));
if (intval($PROFILE_ID) <= 0) {
$arResult['errCode'] = 'ERR_IBLOCK';
-
+
return;
}
if ($typeLoading == 'agent') {
@@ -1055,7 +1058,7 @@ class intaro_retailcrm extends CModule
}
}
- function DoUninstall()
+ function DoUninstall()
{
global $APPLICATION;
@@ -1086,23 +1089,23 @@ class intaro_retailcrm extends CModule
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_NUMBERS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_CANSEL_ORDER);
-
+
COption::RemoveOption($this->MODULE_ID, $this->CRM_INVENTORIES_UPLOAD);
COption::RemoveOption($this->MODULE_ID, $this->CRM_STORES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_SHOPS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_IBLOCKS_INVENTORIES);
-
+
COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICES_UPLOAD);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICE_SHOPS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_IBLOCKS_PRICES);
-
+
COption::RemoveOption($this->MODULE_ID, $this->CRM_COLLECTOR);
COption::RemoveOption($this->MODULE_ID, $this->CRM_COLL_KEY);
-
+
COption::RemoveOption($this->MODULE_ID, $this->CRM_UA);
COption::RemoveOption($this->MODULE_ID, $this->CRM_UA_KEYS);
-
+
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_VERSION);
COption::RemoveOption($this->MODULE_ID, $this->HISTORY_TIME);
@@ -1135,7 +1138,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_UNINSTALL_TITLE'), $this->INSTALL_PATH . '/unstep1.php'
);
- }
+ }
function CopyFiles()
{
@@ -1170,18 +1173,18 @@ class intaro_retailcrm extends CModule
$filename
) {
$strVars = "";
- foreach ($iblocks as $key => $val)
+ foreach ($iblocks as $key => $val)
$strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&';
- foreach ($propertiesSKU as $iblock => $arr)
+ foreach ($propertiesSKU as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
- foreach ($propertiesUnitSKU as $iblock => $arr)
+ foreach ($propertiesUnitSKU as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
- foreach ($propertiesProduct as $iblock => $arr)
+ foreach ($propertiesProduct as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
- foreach ($propertiesUnitProduct as $iblock => $arr)
+ foreach ($propertiesUnitProduct as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
if ($propertiesHbSKU) {
@@ -1201,7 +1204,7 @@ class intaro_retailcrm extends CModule
return $strVars;
}
-
+
function historyLoad($api, $method)
{
$page = null;
@@ -1244,10 +1247,10 @@ class intaro_retailcrm extends CModule
return $end['id'];
}
-
+
if (isset($history['history'])) {
$end = array_pop($history['history']);
-
+
break;
} else {
$page--;
@@ -1263,7 +1266,7 @@ class intaro_retailcrm extends CModule
return $end['id'];
}
-
+
function ping($api_host, $api_key)
{
global $APPLICATION;
@@ -1283,7 +1286,7 @@ class intaro_retailcrm extends CModule
}
if ($result->getStatusCode() == 200) {
- COption::SetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, $version);
+ COption::SetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, $version);
$res['sitesList'] = $APPLICATION->ConvertCharsetArray($result->sites, 'utf-8', SITE_CHARSET);
return $res;
diff --git a/intaro.retailcrm/install/step5.php b/intaro.retailcrm/install/step5.php
index 418fd55f..57894d48 100644
--- a/intaro.retailcrm/install/step5.php
+++ b/intaro.retailcrm/install/step5.php
@@ -20,14 +20,13 @@ if (!empty($oldValues)) {
}
?>
-
-