1
0
mirror of synced 2025-01-18 17:01:40 +03:00
This commit is contained in:
Akolzin Dmitry 2018-10-04 16:28:14 +03:00
parent b22d464b56
commit 038739d45f
12 changed files with 474 additions and 414 deletions

View File

@ -1,3 +1,9 @@
## 2018-10-04 v.2.3.11
* Добавлен учет настроек часового пояса при создании заказа
* Устранено удаление событий изменения оплат при переводе выгрузки на агент
* Добавлена возможность указать свойство в настройках экспорта, из которого будет подставляться картинка, если отсутствует в "Подробно" и "Анонс"
* Добавлена подстановка домена в ссылках каталога в зависимости от пренадлежности инфоблока к сайту
## 2018-09-26 v.2.3.10
* Исправлена некорректная генерация скрипта UA
* Исправлена выгрузка остатков, если для товара указано более 50 складов

View File

@ -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;
@ -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;
}
@ -311,14 +321,21 @@ class RetailCrmICML
}
}
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,6 +409,19 @@ class RetailCrmICML
$stringOffers = "";
foreach ($products as $product) {
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;
}
// Get properties of product
$resPropertiesProduct = Array();
foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
@ -424,14 +435,16 @@ class RetailCrmICML
} 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];
$field = $this->highloadblockProductProperties[$tableName][$id][$key];
$resPropertiesProduct[$key] = $propVal[$field];
}
@ -461,8 +474,17 @@ class RetailCrmICML
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['PICTURE'] = $product['PICTURE'];
}
$offer['PRODUCT_NAME'] = $product["NAME"];
@ -568,7 +590,10 @@ class RetailCrmICML
$arOffer['DETAIL_PAGE_URL'] = str_replace("#SECTION_PATH#", $path, $arOffer['DETAIL_PAGE_URL']);
}
if (isset($arOffer["PICTURE"]) && $arOffer["PICTURE"]) {
$offer .= "<picture>" . $this->PrepareValue($arOffer["PICTURE"]) . "</picture>\n";
}
$offer .= "<url>" . $this->protocol . $this->serverName . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "</url>\n";
$offer .= "<price>" . $this->PrepareValue($arOffer['PRICE']) . "</price>\n";

View File

@ -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]] : '',
@ -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(),

View File

@ -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']] : '',
@ -202,7 +202,11 @@ 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;
}
@ -217,7 +221,11 @@ class RetailCrmOrder
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;
}
@ -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(),

View File

@ -1,3 +1,4 @@
- Исправлена некорректная генерация скрипта UA
- Улучшена выгрузка остатков по складам в retailCRM
- Улучшена обработка истории изменений заказов
- Добавлен учет настроек часового пояса при создании заказа
- Устранено удаление событий изменения оплат при переводе выгрузки на агент
- Добавлена возможность указать свойство в настройках экспорта, из которого будет подставляться картинка, если отсутствует в "Подробно" и "Анонс"
- Добавлена подстановка домена в ссылках каталога в зависимости от пренадлежности инфоблока к сайту

View File

@ -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();

View File

@ -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;
}

View File

@ -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;

View File

@ -20,7 +20,6 @@ if (!empty($oldValues)) {
}
?>
<style type="text/css">
.iblock-export-table-display-none {
display: none;
@ -45,10 +44,10 @@ if (!empty($oldValues)) {
"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_size" , "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'),
@ -64,6 +63,7 @@ if (!empty($oldValues)) {
"length" => Array("LENGTH", "DLINA"),
"width" => Array("WIDTH", "SHIRINA"),
"height" => Array("HEIGHT", "VISOTA"),
"picture" => Array("PICTURE", "PICTURE"),
);
$units = Array(
@ -84,8 +84,6 @@ if (!empty($oldValues)) {
'mass' => 'g'
);
$boolAll = false;
$intCountChecked = 0;
$intCountAvailIBlock = 0;

View File

@ -1,5 +1,5 @@
<?
$arModuleVersion = array(
"VERSION" => "2.3.10",
"VERSION_DATE" => "2018-09-26 13:30:00"
"VERSION" => "2.3.11",
"VERSION_DATE" => "2018-10-04 16:15:00"
);

View File

@ -28,6 +28,7 @@ $MESS["PROPERTY_WEIGHT_HEADER_NAME"] = "Вес (габариты)";
$MESS["PROPERTY_LENGTH_HEADER_NAME"] = "Длина (габариты)";
$MESS["PROPERTY_WIDTH_HEADER_NAME"] = "Ширина (габариты)";
$MESS["PROPERTY_HEIGHT_HEADER_NAME"] = "Высота (габариты)";
$MESS["PROPERTY_PICTURE_HEADER_NAME"] = "Фото";
$MESS["PROPERTY_SIZE_HEADER_NAME"] = "Размер";
$MESS["SELECT_FIELD_NAME"] = "Поле";
$MESS["SELECT_PROPERTY_NAME"] = "Свойства";

View File

@ -268,7 +268,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
$previousDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0);
//order discharge mode
// 0 - agent
@ -280,14 +279,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
UnRegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave");
UnRegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder");
UnRegisterModuleDependences("sale", "OnSaleOrderDeleted", $mid, "RetailCrmEvent", "orderDelete");
} elseif (($orderDischarge != $previousDischarge) && ($orderDischarge == 1)) {
// event dependencies
RegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave");
RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder");
RegisterModuleDependences("sale", "OnSaleOrderDeleted", $mid, "RetailCrmEvent", "orderDelete");
RegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $mid, "RetailCrmEvent", "paymentSave");
RegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $mid, "RetailCrmEvent", "paymentDelete");
}
$orderPropsArr = array();