1
0
mirror of synced 2024-11-25 14:56:09 +03:00

ICML simple product props (#207)

This commit is contained in:
Сергей Чазов 2021-09-08 10:05:09 +03:00 committed by GitHub
parent a3c5cc9632
commit 30ef0ebf8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 1967 additions and 1849 deletions

View File

@ -0,0 +1,12 @@
<?php
return [
'controllers' => [
'value' => [
'namespaces' => [
'\\Intaro\\RetailCrm\\Controller' => 'api'
],
],
'readonly' => true,
]
];

View File

@ -270,6 +270,36 @@ class RetailcrmConfigProvider
return static::setOption(RetailcrmConstants::CRM_USERS_MAP, serialize($userMap)); return static::setOption(RetailcrmConstants::CRM_USERS_MAP, serialize($userMap));
} }
/**
* @param $profileId
*
* @return false|string|null
*/
public static function getCrmBasePrice($profileId)
{
return self::getOption(RetailcrmConstants::CRM_CATALOG_BASE_PRICE . '_' . $profileId, 1);
}
public static function setProfileBasePrice($profileId, $priceTypes): void
{
self::setOption(
RetailcrmConstants::CRM_CATALOG_BASE_PRICE . '_' . $profileId,
htmlspecialchars(trim($priceTypes))
);
}
/**
* @return string
*/
public static function getDefaultIcmlPath(): string
{
return (COption::GetOptionString(
'catalog',
'export_default_path',
'/bitrix/catalog_export/'))
. 'retailcrm.xml';
}
/** /**
* setOnlineConsultantScript * setOnlineConsultantScript
* *

View File

@ -7,6 +7,8 @@ use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetupProps;
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetupPropsCategories; use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetupPropsCategories;
use Intaro\RetailCrm\Repository\CatalogRepository; use Intaro\RetailCrm\Repository\CatalogRepository;
/** @var $SETUP_FILE_NAME */
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/export_run.php')) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/export_run.php')) {
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/export_run.php'); require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/export_run.php');
} else { } else {
@ -54,7 +56,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
$iblockPropertyUnitProduct = []; $iblockPropertyUnitProduct = [];
foreach ($iblockProperties as $prop) { foreach ($iblockProperties as $prop) {
$skuUnitProps = ('IBLOCK_PROPERTY_UNIT_SKU' . "_" . $prop); $skuUnitProps = ('iblockPropertyUnitSku_' . $prop);
$skuUnitProps = $$skuUnitProps; $skuUnitProps = $$skuUnitProps;
if (is_array($skuUnitProps)) { if (is_array($skuUnitProps)) {
@ -63,7 +65,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
} }
} }
$skuProps = ('IBLOCK_PROPERTY_SKU' . "_" . $prop); $skuProps = ('iblockPropertySku_' . $prop);
$skuProps = $$skuProps; $skuProps = $$skuProps;
if (is_array($skuProps)) { if (is_array($skuProps)) {
foreach ($skuProps as $iblock => $val) { foreach ($skuProps as $iblock => $val) {
@ -84,7 +86,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
} }
} }
$productUnitProps = "IBLOCK_PROPERTY_UNIT_PRODUCT" . "_" . $prop; $productUnitProps = 'iblockPropertyUnitProduct_' . $prop;
$productUnitProps = $$productUnitProps; $productUnitProps = $$productUnitProps;
if (is_array($productUnitProps)) { if (is_array($productUnitProps)) {
foreach ($productUnitProps as $iblock => $val) { foreach ($productUnitProps as $iblock => $val) {
@ -92,7 +94,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
} }
} }
$productProps = "IBLOCK_PROPERTY_PRODUCT" . "_" . $prop; $productProps = "iblockPropertyProduct_" . $prop;
$productProps = $$productProps; $productProps = $$productProps;
if (is_array($productProps)) { if (is_array($productProps)) {
foreach ($productProps as $iblock => $val) { foreach ($productProps as $iblock => $val) {
@ -116,16 +118,16 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
$productPictures = []; $productPictures = [];
if (is_array($IBLOCK_PROPERTY_PRODUCT_picture)) { if (is_array($iblockPropertyProduct_picture)) {
foreach ($IBLOCK_PROPERTY_PRODUCT_picture as $key => $value) { foreach ($iblockPropertyProduct_picture as $key => $value) {
$productPictures[$key] = $value; $productPictures[$key] = $value;
} }
} }
$skuPictures = []; $skuPictures = [];
if (is_array($IBLOCK_PROPERTY_SKU_picture)) { if (is_array($iblockPropertySku_picture)) {
foreach ($IBLOCK_PROPERTY_SKU_picture as $key => $value) { foreach ($iblockPropertySku_picture as $key => $value) {
$skuPictures[$key] = $value; $skuPictures[$key] = $value;
} }
} }
@ -142,10 +144,10 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
$fileSetup = new XmlSetup($xmlProps); $fileSetup = new XmlSetup($xmlProps);
$fileSetup->profileId = $profile_id; $fileSetup->profileId = $profile_id;
$fileSetup->iblocksForExport = $IBLOCK_EXPORT; $fileSetup->iblocksForExport = $iblockExport;
$fileSetup->maxOffersValue = $MAX_OFFERS_VALUE ?? null; $fileSetup->maxOffersValue = $maxOffersValue ?? null;
$fileSetup->filePath = $SETUP_FILE_NAME; $fileSetup->filePath = $SETUP_FILE_NAME;
$fileSetup->loadPurchasePrice = $LOAD_PURCHASE_PRICE === 'Y'; $fileSetup->loadPurchasePrice = $loadPurchasePrice === 'Y';
$fileSetup->basePriceId = CatalogRepository::getBasePriceId($fileSetup->profileId); $fileSetup->basePriceId = CatalogRepository::getBasePriceId($fileSetup->profileId);
$logger = Logger::getInstance('/bitrix/catalog_export/'); $logger = Logger::getInstance('/bitrix/catalog_export/');

File diff suppressed because it is too large Load Diff

View File

@ -6,13 +6,17 @@
* Class name: intaro_retailcrm * Class name: intaro_retailcrm
*/ */
global $MESS; global $MESS;
use Bitrix\Highloadblock\HighloadBlockTable;
use Bitrix\Main\Context; use Bitrix\Main\Context;
use Bitrix\Sale\EventActions;
use Intaro\RetailCrm\Icml\IcmlDirector; use Intaro\RetailCrm\Icml\IcmlDirector;
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetup; use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetup;
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetupProps; use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetupProps;
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetupPropsCategories; use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetupPropsCategories;
use Intaro\RetailCrm\Repository\CatalogRepository; use Intaro\RetailCrm\Repository\CatalogRepository;
use Intaro\RetailCrm\Vendor\Symfony\Component\Process\PhpExecutableFinder; use Intaro\RetailCrm\Vendor\Symfony\Component\Process\PhpExecutableFinder;
use RetailCrm\ApiClient;
use RetailCrm\Exception\CurlException; use RetailCrm\Exception\CurlException;
use RetailCrm\Response\ApiResponse; use RetailCrm\Response\ApiResponse;
@ -138,7 +142,9 @@ class intaro_retailcrm extends CModule
include($this->INSTALL_PATH . '/../classes/general/RCrmActions.php'); include($this->INSTALL_PATH . '/../classes/general/RCrmActions.php');
include($this->INSTALL_PATH . '/../classes/general/user/RetailCrmUser.php'); include($this->INSTALL_PATH . '/../classes/general/user/RetailCrmUser.php');
include($this->INSTALL_PATH . '/../classes/general/events/RetailCrmEvent.php'); include($this->INSTALL_PATH . '/../classes/general/events/RetailCrmEvent.php');
include($this->INSTALL_PATH . '/../classes/general/RetailcrmConfigProvider.php');
include($this->INSTALL_PATH . '/../lib/model/bitrix/xml/offerparam.php'); include($this->INSTALL_PATH . '/../lib/model/bitrix/xml/offerparam.php');
include($this->INSTALL_PATH . '/../lib/icml/settingsservice.php');
include($this->INSTALL_PATH . '/../lib/component/agent.php'); include($this->INSTALL_PATH . '/../lib/component/agent.php');
include($this->INSTALL_PATH . '/../lib/model/bitrix/xml/selectparams.php'); include($this->INSTALL_PATH . '/../lib/model/bitrix/xml/selectparams.php');
include($this->INSTALL_PATH . '/../lib/model/bitrix/xml/unit.php'); include($this->INSTALL_PATH . '/../lib/model/bitrix/xml/unit.php');
@ -346,7 +352,7 @@ class intaro_retailcrm extends CModule
return; return;
} }
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key); $this->RETAIL_CRM_API = new ApiClient($api_host, $api_key);
COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize($siteCode)); COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize($siteCode));
} else { } else {
$api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
@ -380,7 +386,7 @@ class intaro_retailcrm extends CModule
return; return;
} }
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key); $this->RETAIL_CRM_API = new 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_HOST_OPTION, $api_host);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize(array())); COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize(array()));
@ -473,7 +479,7 @@ class intaro_retailcrm extends CModule
// api load // api load
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); $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_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key); $this->RETAIL_CRM_API = new ApiClient($api_host, $api_key);
//bitrix orderTypesList //bitrix orderTypesList
$arResult['arSites'] = RCrmActions::SitesList(); $arResult['arSites'] = RCrmActions::SitesList();
@ -714,10 +720,10 @@ class intaro_retailcrm extends CModule
&& $_POST['ajax'] == 1 && $_POST['ajax'] == 1
) { ) {
CModule::IncludeModule('highloadblock'); CModule::IncludeModule('highloadblock');
$rsData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => $_POST['table']))); $rsData = HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => $_POST['table'])));
$hlblockArr = $rsData->Fetch(); $hlblockArr = $rsData->Fetch();
$hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getById($hlblockArr["ID"])->fetch(); $hlblock = HighloadBlockTable::getById($hlblockArr["ID"])->fetch();
$entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock); $entity = HighloadBlockTable::compileEntity($hlblock);
$hbFields = $entity->getFields(); $hbFields = $entity->getFields();
$hlblockList['table'] = $hlblockArr["TABLE_NAME"]; $hlblockList['table'] = $hlblockArr["TABLE_NAME"];
@ -741,7 +747,7 @@ class intaro_retailcrm extends CModule
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); $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_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$api = new \RetailCrm\ApiClient($api_host, $api_key); $api = new ApiClient($api_host, $api_key);
$customerH = self::historyLoad($api, 'customersHistory'); $customerH = self::historyLoad($api, 'customersHistory');
COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY, $customerH); COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY, $customerH);
@ -839,10 +845,10 @@ class intaro_retailcrm extends CModule
); );
} }
if (!isset($_POST['IBLOCK_EXPORT'])) { if (!isset($_POST['iblockExport'])) {
$arResult['errCode'] = 'ERR_FIELDS_IBLOCK'; $arResult['errCode'] = 'ERR_FIELDS_IBLOCK';
} else { } else {
$iblocks = $_POST['IBLOCK_EXPORT']; $iblocks = $_POST['iblockExport'];
} }
$hlblockModule = false; $hlblockModule = false;
@ -850,11 +856,11 @@ class intaro_retailcrm extends CModule
if (CModule::IncludeModule('highloadblock')) { if (CModule::IncludeModule('highloadblock')) {
$hlblockModule = true; $hlblockModule = true;
$hlblockList = array(); $hlblockList = array();
$hlblockListDb = \Bitrix\Highloadblock\HighloadBlockTable::getList(); $hlblockListDb = HighloadBlockTable::getList();
while ($hlblockArr = $hlblockListDb->Fetch()) { while ($hlblockArr = $hlblockListDb->Fetch()) {
$hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getById($hlblockArr["ID"])->fetch(); $hlblock = HighloadBlockTable::getById($hlblockArr["ID"])->fetch();
$entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock); $entity = HighloadBlockTable::compileEntity($hlblock);
$hbFields = $entity->getFields(); $hbFields = $entity->getFields();
$hlblockList[$hlblockArr["TABLE_NAME"]]['LABEL'] = $hlblockArr["NAME"]; $hlblockList[$hlblockArr["TABLE_NAME"]]['LABEL'] = $hlblockArr["NAME"];
@ -876,15 +882,15 @@ class intaro_retailcrm extends CModule
"picture" => "picture", "picture" => "picture",
); );
$propertiesSKU = array(); $propertiesSKU = [];
$propertiesUnitSKU = array(); $propertiesUnitSKU = [];
$propertiesHbSKU = array(); $propertiesHbSKU = [];
foreach ($iblockProperties as $prop) { foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) { foreach ($_POST['iblockPropertySku'. '_' . $prop] as $iblock => $val) {
$propertiesSKU[$iblock][$prop] = $val; $propertiesSKU[$iblock][$prop] = $val;
} }
foreach ($_POST['IBLOCK_PROPERTY_UNIT_SKU'. '_' . $prop] as $iblock => $val) { foreach ($_POST['iblockPropertyUnitSku'. '_' . $prop] as $iblock => $val) {
$propertiesUnitSKU[$iblock][$prop] = $val; $propertiesUnitSKU[$iblock][$prop] = $val;
} }
@ -897,15 +903,15 @@ class intaro_retailcrm extends CModule
} }
} }
$propertiesProduct = array(); $propertiesProduct = [];
$propertiesUnitProduct = array(); $propertiesUnitProduct = [];
$propertiesHbProduct = array(); $propertiesHbProduct = [];
foreach ($iblockProperties as $prop) { foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) { foreach ($_POST['iblockPropertyProduct'. '_' . $prop] as $iblock => $val) {
$propertiesProduct[$iblock][$prop] = $val; $propertiesProduct[$iblock][$prop] = $val;
} }
foreach ($_POST['IBLOCK_PROPERTY_UNIT_PRODUCT'. '_' . $prop] as $iblock => $val) { foreach ($_POST['iblockPropertyUnitProduct'. '_' . $prop] as $iblock => $val) {
$propertiesUnitProduct[$iblock][$prop] = $val; $propertiesUnitProduct[$iblock][$prop] = $val;
} }
@ -930,14 +936,14 @@ class intaro_retailcrm extends CModule
$typeLoading = $_POST['TYPE_LOADING']; $typeLoading = $_POST['TYPE_LOADING'];
} }
if (!isset($_POST['MAX_OFFERS_VALUE'])) { if (!isset($_POST['maxOffersValue'])) {
$maxOffers = null; $maxOffers = null;
} else { } else {
$maxOffers = (int) $_POST['MAX_OFFERS_VALUE']; $maxOffers = (int) $_POST['maxOffersValue'];
} }
if (!isset($_POST['SETUP_PROFILE_NAME'])) { if (!isset($_POST['SETUP_PROFILE_NAME'])) {
$profileName = ""; $profileName = '';
} else { } else {
$profileName = $_POST['SETUP_PROFILE_NAME']; $profileName = $_POST['SETUP_PROFILE_NAME'];
} }
@ -946,22 +952,24 @@ class intaro_retailcrm extends CModule
$arResult['errCode'] = 'ERR_FIELDS_PROFILE'; $arResult['errCode'] = 'ERR_FIELDS_PROFILE';
} }
if ($filename == "") { if ($filename === '') {
$arResult['errCode'] = 'ERR_FIELDS_FILE'; $arResult['errCode'] = 'ERR_FIELDS_FILE';
} }
if (isset($arResult['errCode']) && $arResult['errCode']) { if (isset($arResult['errCode']) && $arResult['errCode']) {
$arOldValues = array( $arOldValues = [
'IBLOCK_EXPORT' => $iblocks, 'iblockExport' => $iblocks,
'IBLOCK_PROPERTY_SKU' => $propertiesSKU, 'iblockPropertySku' => $propertiesSKU,
'IBLOCK_PROPERTY_UNIT_SKU' => $propertiesUnitSKU, 'iblockPropertyUnitSku' => $propertiesUnitSKU,
'IBLOCK_PROPERTY_PRODUCT' => $propertiesProduct, 'iblockPropertyProduct' => $propertiesProduct,
'IBLOCK_PROPERTY_UNIT_PRODUCT' => $propertiesUnitProduct, 'iblockPropertyUnitProduct' => $propertiesUnitProduct,
'SETUP_FILE_NAME' => $filename, 'SETUP_FILE_NAME' => $filename,
'SETUP_PROFILE_NAME' => $profileName, 'SETUP_PROFILE_NAME' => $profileName,
'MAX_OFFERS_VALUE' => $maxOffers 'maxOffersValue' => $maxOffers,
); ];
global $oldValues; global $oldValues;
$oldValues = $arOldValues; $oldValues = $arOldValues;
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
@ -973,7 +981,7 @@ class intaro_retailcrm extends CModule
RegisterModule($this->MODULE_ID); RegisterModule($this->MODULE_ID);
RegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder"); RegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder");
RegisterModuleDependences("main", "OnAfterUserUpdate", $this->MODULE_ID, "RetailCrmEvent", "OnAfterUserUpdate"); RegisterModuleDependences("main", "OnAfterUserUpdate", $this->MODULE_ID, "RetailCrmEvent", "OnAfterUserUpdate");
RegisterModuleDependences("sale", \Bitrix\Sale\EventActions::EVENT_ON_ORDER_SAVED, $this->MODULE_ID, "RetailCrmEvent", "orderSave"); RegisterModuleDependences("sale", EventActions::EVENT_ON_ORDER_SAVED, $this->MODULE_ID, "RetailCrmEvent", "orderSave");
RegisterModuleDependences("sale", "OnSaleOrderDeleted", $this->MODULE_ID, "RetailCrmEvent", "orderDelete"); RegisterModuleDependences("sale", "OnSaleOrderDeleted", $this->MODULE_ID, "RetailCrmEvent", "orderDelete");
RegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "paymentSave"); RegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "paymentSave");
RegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $this->MODULE_ID, "RetailCrmEvent", "paymentDelete"); RegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $this->MODULE_ID, "RetailCrmEvent", "paymentDelete");
@ -1015,12 +1023,15 @@ class intaro_retailcrm extends CModule
} }
} }
$setupVars = $this->getProfileSetupVars( $setupVars = $this->getProfileSetupVars(
$iblocks, $iblocks,
$propertiesProduct, [
$propertiesUnitProduct, 'iblockPropertySku' => $propertiesSKU,
$propertiesSKU, 'iblockPropertyUnitSku' => $propertiesUnitSKU,
$propertiesUnitSKU, 'iblockPropertyProduct' => $propertiesProduct,
'iblockPropertyUnitProduct' => $propertiesUnitProduct,
],
$propertiesHbSKU, $propertiesHbSKU,
$propertiesHbProduct, $propertiesHbProduct,
$filename, $filename,
@ -1166,7 +1177,7 @@ class intaro_retailcrm extends CModule
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); $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_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$api_version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0); $api_version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0);
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key); $this->RETAIL_CRM_API = new ApiClient($api_host, $api_key);
RCrmActions::sendConfiguration($this->RETAIL_CRM_API, $api_version); RCrmActions::sendConfiguration($this->RETAIL_CRM_API, $api_version);
@ -1202,7 +1213,7 @@ class intaro_retailcrm extends CModule
include($this->INSTALL_PATH . '/../classes/general/history/RetailCrmHistory_v5.php'); include($this->INSTALL_PATH . '/../classes/general/history/RetailCrmHistory_v5.php');
} }
$retail_crm_api = new \RetailCrm\ApiClient($api_host, $api_key); $retail_crm_api = new ApiClient($api_host, $api_key);
CAgent::RemoveAgent("RCrmActions::orderAgent();", $this->MODULE_ID); CAgent::RemoveAgent("RCrmActions::orderAgent();", $this->MODULE_ID);
CAgent::RemoveAgent("RetailCrmInventories::inventoriesUpload();", $this->MODULE_ID); CAgent::RemoveAgent("RetailCrmInventories::inventoriesUpload();", $this->MODULE_ID);
@ -1256,7 +1267,7 @@ class intaro_retailcrm extends CModule
if (CModule::IncludeModule('sale')) { if (CModule::IncludeModule('sale')) {
UnRegisterModuleDependences( UnRegisterModuleDependences(
"sale", "sale",
\Bitrix\Sale\EventActions::EVENT_ON_ORDER_SAVED, EventActions::EVENT_ON_ORDER_SAVED,
$this->MODULE_ID, $this->MODULE_ID,
"RetailCrmEvent", "RetailCrmEvent",
"orderSave" "orderSave"
@ -1313,8 +1324,9 @@ class intaro_retailcrm extends CModule
function DeleteFiles() function DeleteFiles()
{ {
$rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y')); $rsSites = CSite::GetList($by, $sort, ['DEF' => 'Y']);
$defaultSite = array(); $defaultSite = [];
while ($ar = $rsSites->Fetch()) { while ($ar = $rsSites->Fetch()) {
$defaultSite = $ar; $defaultSite = $ar;
break; break;
@ -1328,45 +1340,54 @@ class intaro_retailcrm extends CModule
function getProfileSetupVars( function getProfileSetupVars(
$iblocks, $iblocks,
$propertiesProduct, $simpleProps,
$propertiesUnitProduct,
$propertiesSKU,
$propertiesUnitSKU,
$propertiesHbSKU, $propertiesHbSKU,
$propertiesHbProduct, $propertiesHbProduct,
$filename, $filename,
$maxOffers $maxOffers
) { ): string {
$strVars = ""; $strVars = '';
foreach ($iblocks as $key => $val)
$strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; foreach ($iblocks as $key => $val) {
foreach ($propertiesSKU as $iblock => $arr) $strVars .= 'iblockExport[' . $key . ']=' . $val . '&';
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesUnitSKU as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesProduct as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesUnitProduct as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
if ($propertiesHbSKU) {
foreach ($propertiesHbSKU as $table => $arr)
foreach ($arr as $iblock => $val)
foreach ($val as $id => $value)
$strVars .= 'highloadblock' . $table . '_' . $id . '[' . $iblock . ']=' . $value . '&';
} }
foreach ($simpleProps as $propType => $props) {
$strVars = $this->addToStrVars($strVars, $propType, $props);
}
if ($propertiesHbSKU) {
foreach ($propertiesHbSKU as $table => $arr) {
$strVars = $this->addToStrVars($strVars, 'highloadblock' . $table, $arr);
}
}
if ($propertiesHbProduct) { if ($propertiesHbProduct) {
foreach ($propertiesHbProduct as $table => $arr) foreach ($propertiesHbProduct as $table => $arr) {
foreach ($arr as $iblock => $val) $strVars = $this->addToStrVars($strVars, 'highloadblock_product' . $table, $arr);
foreach ($val as $id => $value) }
$strVars .= 'highloadblock_product' . $table . '_' . $id . '[' . $iblock . ']=' . $value . '&';
} }
$strVars .= 'SETUP_FILE_NAME=' . urlencode($filename); $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename);
$strVars .= '&MAX_OFFERS_VALUE=' . urlencode($maxOffers); $strVars .= '&maxOffersValue=' . urlencode($maxOffers);
return $strVars;
}
/**
* @param string $strVars
* @param string $propType
* @param array $props
*
* @return string
*/
public function addToStrVars(string $strVars, string $propType, array $props): string
{
foreach ($props as $iblock => $arr) {
foreach ($arr as $id => $val) {
$strVars .= $propType . '_' . $id . '[' . $iblock . ']=' . $val . '&';
}
}
return $strVars; return $strVars;
} }

View File

@ -1,698 +1,12 @@
<?php <h3><?=GetMessage('EXPORT_CATALOGS_INFO')?></h3>
if(!check_bitrix_sessid()) return;
IncludeModuleLangFile(__FILE__);
__IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro.retailcrm/lang/", "/icml_export_setup.php"));
?>
<h3><?=GetMessage("EXPORT_CATALOGS_INFO");?></h3>
<?php <?php
if(isset($arResult['errCode']) && $arResult['errCode'])
echo CAdminMessage::ShowMessage(GetMessage($arResult['errCode']));
global $oldValues; global $oldValues;
if (!empty($oldValues)) {
$IBLOCK_EXPORT = $oldValues['IBLOCK_EXPORT']; $STEP = 1;
$IBLOCK_PROPERTY_SKU = $oldValues['IBLOCK_PROPERTY_SKU']; $ACTION = 'EXPORT_SETUP';
$IBLOCK_PROPERTY_UNIT_SKU = $oldValues['IBLOCK_PROPERTY_UNIT_SKU']; $arOldSetupVars = $oldValues ?? [];
$IBLOCK_PROPERTY_PRODUCT = $oldValues['IBLOCK_PROPERTY_PRODUCT']; $SETUP_PROFILE_NAME = $oldValues['SETUP_PROFILE_NAME'] ?? GetMessage('PROFILE_NAME_EXAMPLE');
$IBLOCK_PROPERTY_UNIT_PRODUCT = $oldValues['IBLOCK_PROPERTY_UNIT_PRODUCT'];
$SETUP_FILE_NAME = $oldValues['SETUP_FILE_NAME']; require_once __DIR__ . '/../export/export_setup.php';
$SETUP_PROFILE_NAME = $oldValues['SETUP_PROFILE_NAME'];
$MAX_OFFERS_VALUE = $oldValues['MAX_OFFERS_VALUE'];
}
?> ?>
<style type="text/css">
.iblock-export-table-display-none {
display: none;
}
</style>
<form method="post" action="<?php echo $APPLICATION->GetCurPage(); ?>" >
<h3><?=GetMessage("SETTINGS_INFOBLOCK");?></h3>
<font class="text"><?=GetMessage("EXPORT_CATALOGS");?><br><br></font>
<?
if (!isset($IBLOCK_EXPORT) || !is_array($IBLOCK_EXPORT))
{
$IBLOCK_EXPORT = array();
}
$iblockPropertiesName = Array(
"article" => GetMessage("PROPERTY_ARTICLE_HEADER_NAME"),
"manufacturer" => GetMessage("PROPERTY_MANUFACTURER_HEADER_NAME"),
"color" => GetMessage("PROPERTY_COLOR_HEADER_NAME"),
"size" => GetMessage("PROPERTY_SIZE_HEADER_NAME"),
"weight" => GetMessage("PROPERTY_WEIGHT_HEADER_NAME"),
"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'),
"height" => Array("code" => "catalog_height" , "name" => GetMessage("SELECT_HEIGHT_PROPERTY_NAME"), 'unit' => 'length'),
);
$iblockPropertiesHint = Array(
"article" => Array("ARTICLE", "ART", "ARTNUMBER", "ARTICUL", "ARTIKUL"),
"manufacturer" => Array("MANUFACTURER", "PROISVODITEL", "PROISVOD", "PROISV"),
"color" => Array("COLOR", "CVET"),
"size" => Array("SIZE", "RAZMER"),
"weight" => Array("WEIGHT", "VES", "VEC"),
"length" => Array("LENGTH", "DLINA"),
"width" => Array("WIDTH", "SHIRINA"),
"height" => Array("HEIGHT", "VISOTA"),
"picture" => Array("PICTURE", "PICTURE"),
);
$units = Array(
'length' => Array(
'mm' => GetMessage("UNIT_MEASUREMENT_MM"),
'cm' => GetMessage("UNIT_MEASUREMENT_CM"),
'm' => GetMessage("UNIT_MEASUREMENT_M"),
),
'mass' => Array(
'mg' => GetMessage("UNIT_MEASUREMENT_MG"),
'g' => GetMessage("UNIT_MEASUREMENT_G"),
'kg' => GetMessage("UNIT_MEASUREMENT_KG"),
)
);
$hintUnit = Array(
'length' => 'mm',
'mass' => 'g'
);
$boolAll = false;
$intCountChecked = 0;
$intCountAvailIBlock = 0;
$arIBlockList = array();
$db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W'));
while ($iblock = $db_res->Fetch())
{
if ($arCatalog = CCatalog::GetByIDExt($iblock["ID"]))
{
if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P")
{
$propertiesSKU = null;
if ($arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P")
{
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock["ID"]);
$db_properties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], Array());
while($prop = $db_properties->Fetch())
$propertiesSKU[] = $prop;
$oldPropertySKU = null;
if (isset($IBLOCK_PROPERTY_SKU[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertySKU[$key] = $IBLOCK_PROPERTY_SKU[$iblock['ID']][$key];
}
}
$oldPropertyUnitSKU = null;
if (isset($IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyUnitSKU[$key] = $IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']][$key];
}
}
}
$propertiesProduct = null;
$db_properties = CIBlock::GetProperties($iblock['ID'], Array());
while($prop = $db_properties->Fetch())
$propertiesProduct[] = $prop;
$oldPropertyProduct = null;
if (isset($IBLOCK_PROPERTY_PRODUCT[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyProduct[$key] = $IBLOCK_PROPERTY_PRODUCT[$iblock['ID']][$key];
}
}
$oldPropertyUnitProduct = null;
if (isset($IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyUnitProduct[$key] = $IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']][$key];
}
}
$arSiteList = array();
$rsSites = CIBlock::GetSite($iblock["ID"]);
while ($arSite = $rsSites->Fetch())
{
$arSiteList[] = $arSite["SITE_ID"];
}
if (count($IBLOCK_EXPORT) != 0)
$boolExport = (in_array($iblock['ID'], $IBLOCK_EXPORT));
else
$boolExport = true;
$arIBlockList[] = array(
'ID' => $iblock['ID'],
'NAME' => $iblock['NAME'],
'IBLOCK_TYPE_ID' => $iblock['IBLOCK_TYPE_ID'],
'IBLOCK_EXPORT' => $boolExport,
'PROPERTIES_SKU' => $propertiesSKU,
'PROPERTIES_PRODUCT' => $propertiesProduct,
'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU,
'OLD_PROPERTY_UNIT_SKU_SELECT' => $oldPropertyUnitSKU,
'OLD_PROPERTY_PRODUCT_SELECT' => $oldPropertyProduct,
'OLD_PROPERTY_UNIT_PRODUCT_SELECT' => $oldPropertyUnitProduct,
'SITE_LIST' => '('.implode(' ',$arSiteList).')',
);
if ($boolExport)
$intCountChecked++;
$intCountAvailIBlock++;
}
}
}
if (count($IBLOCK_EXPORT) != 0) {
if ($intCountChecked == $intCountAvailIBlock)
$boolAll = true;
} else {
$intCountChecked = $intCountAvailIBlock;
$boolAll = true;
}
?>
<font class="text" style="font-weight: bold;"><?=GetMessage("CHECK_ALL_INFOBLOCKS");?></font>
<input
style="vertical-align: middle;"
type="checkbox"
name="icml_export_all"
id="icml_export_all"
value="Y"
onclick="checkAll(this,<? echo $intCountAvailIBlock; ?>);"
<? echo ($boolAll ? ' checked' : ''); ?>>
</br>
</br>
<div>
<? $checkBoxCounter = 0;?>
<? foreach ($arIBlockList as $key => $arIBlock):?>
<div>
<div>
<font class="text" style="font-weight: bold;"><? echo htmlspecialcharsex("[".$arIBlock["IBLOCK_TYPE_ID"]."] ".$arIBlock["NAME"]." ".$arIBlock['SITE_LIST']); ?></font>
<input
type="checkbox"
name="IBLOCK_EXPORT[<?=$arIBlock["ID"]?>]"
id="IBLOCK_EXPORT<?=++$checkBoxCounter?>"
value="<?=$arIBlock["ID"]?>"
<? if ($arIBlock['IBLOCK_EXPORT']) echo " checked"; ?>
onclick="checkOne(this,<? echo $intCountAvailIBlock; ?>);"
>
</div>
<br>
<div id="IBLOCK_EXPORT_TABLE<?=$checkBoxCounter?>" class="IBLOCK_EXPORT_TABLE" data-type="<?=$arIBlock["ID"]?>">
<table class="adm-list-table" id="export_setup" <?=($arIBlock['PROPERTIES_SKU'] == null ? 'style="width: 66%;"': "" )?> >
<thead>
<tr class="adm-list-table-header">
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?=GetMessage("LOADED_PROPERTY");?></div>
</td>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?=GetMessage("PROPERTY_PRODUCT_HEADER_NAME");?></div>
</td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?=GetMessage("PROPERTY_OFFER_HEADER_NAME");?></div>
</td>
<? endif;?>
</tr>
</thead>
<tbody>
<? foreach ($iblockPropertiesName as $key => $property): ?>
<? $productSelected = false;?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell">
<? echo htmlspecialcharsex($property); ?>
</td>
<td class="adm-list-table-cell">
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export"
data-type="<?=$key?>"
onchange="propertyChange(this);">
<option value=""></option>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName) && $arIBlock['PROPERTIES_SKU'] == null) :?>
<optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?>
<? if ($keyField == $key): ?>
<option value="<?=$field['code'];?>"
<?
if ($arIBlock['OLD_PROPERTY_PRODUCT_SELECT'] != null) {
if ($field['code'] == $arIBlock['OLD_PROPERTY_PRODUCT_SELECT'][$key] ) {
echo " selected";
$productSelected = true;
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($field['code'] == $hint ) {
echo " selected";
$productSelected = true;
break;
}
}
}
?>
>
<?=$field['name'];?>
</option>
<? endif; ?>
<? endforeach;?>
</optgroup>
<optgroup label="<?=GetMessage("SELECT_PROPERTY_NAME");?>">
<?endif; ?>
<? foreach ($arIBlock['PROPERTIES_PRODUCT'] as $prop): ?>
<option value="<?=$prop['CODE'] ?>"
<?
if ($prop['USER_TYPE'] == 'directory') {
echo 'class="highloadblock-product"';
echo 'id="'. $prop['USER_TYPE_SETTINGS']['TABLE_NAME'] .'"';
} else {
echo 'class="not-highloadblock"';
}
if ($arIBlock['OLD_PROPERTY_PRODUCT_SELECT'] != null) {
if ($prop["CODE"] == $arIBlock['OLD_PROPERTY_PRODUCT_SELECT'][$key] ) {
echo " selected";
$productSelected = true;
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($prop["CODE"] == $hint ) {
echo " selected";
$productSelected = true;
break;
}
}
}
?>
>
<?=$prop["NAME"];?>
</option>
<? endforeach;?>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)){?>
</optgroup>
<?}?>
</select>
<?if (array_key_exists($key, $iblockFieldsName)) :?>
<select
style="width: 100px; margin-left: 50px;"
id="IBLOCK_PROPERTY_UNIT_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_UNIT_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
>
<? foreach ($units as $unitTypeName => $unitType): ?>
<? if ($unitTypeName == $iblockFieldsName[$key]['unit']): ?>
<? foreach ($unitType as $keyUnit => $unit): ?>
<option value="<?=$keyUnit;?>"
<?
if ($arIBlock['OLD_PROPERTY_UNIT_PRODUCT_SELECT'] != null) {
if ($keyUnit == $arIBlock['OLD_PROPERTY_UNIT_PRODUCT_SELECT'][$key] ) {
echo " selected";
}
} else {
if ($keyUnit == $hintUnit[$unitTypeName]) {
echo " selected";
}
}
?>
>
<?=$unit?>
</option>
<? endforeach;?>
<?endif; ?>
<? endforeach;?>
</select>
<?endif; ?>
</td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell">
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export"
data-type="<?=$key?>"
onchange="propertyChange(this);">
<option value=""></option>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)) :?>
<optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?>
<? if ($keyField == $key) :?>
<option value="<?=$field['code'];?>"
<?
if (!$productSelected) {
if ($arIBlock['OLD_PROPERTY_SKU_SELECT'] != null) {
if ($field['code'] == $arIBlock['OLD_PROPERTY_SKU_SELECT'][$key] ) {
echo " selected";
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($field['code'] == $hint ) {
echo " selected";
break;
}
}
}
}?>
>
<?=$field['name'];?>
</option>
<? endif; ?>
<? endforeach;?>
</optgroup>
<optgroup label="<?=GetMessage("SELECT_PROPERTY_NAME");?>">
<? endif; ?>
<? foreach ($arIBlock['PROPERTIES_SKU'] as $prop): ?>
<option value="<?=$prop['CODE'] ?>"
<?
if ($prop['USER_TYPE'] == 'directory') {
echo 'class="highloadblock"';
echo 'id="'. $prop['USER_TYPE_SETTINGS']['TABLE_NAME'] .'"';
} else {
echo 'class="not-highloadblock"';
}
if (!$productSelected) {
if ($arIBlock['OLD_PROPERTY_SKU_SELECT'] != null) {
if ($prop["CODE"] == $arIBlock['OLD_PROPERTY_SKU_SELECT'][$key] ) {
echo " selected";
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($prop["CODE"] == $hint ) {
echo " selected";
break;
}
}
}
}
?>
>
<?=$prop["NAME"];?>
</option>
<? endforeach;?>
<? if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)) : ?>
</optgroup>
<? endif; ?>
</select>
<?if (array_key_exists($key, $iblockFieldsName)) :?>
<select
style="width: 100px; margin-left: 50px;"
id="IBLOCK_PROPERTY_UNIT_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_UNIT_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
>
<? foreach ($units as $unitTypeName => $unitType): ?>
<? if ($unitTypeName == $iblockFieldsName[$key]['unit']): ?>
<? foreach ($unitType as $keyUnit => $unit): ?>
<option value="<?=$keyUnit;?>"
<?
if ($arIBlock['OLD_PROPERTY_UNIT_SKU_SELECT'] != null) {
if ($keyUnit == $arIBlock['OLD_PROPERTY_UNIT_SKU_SELECT'][$key] ) {
echo " selected";
}
} else {
if ($keyUnit == $hintUnit[$unitTypeName]) {
echo " selected";
}
}
?>
>
<?=$unit?>
</option>
<? endforeach;?>
<?endif; ?>
<? endforeach;?>
</select>
<?endif; ?>
</td>
<? endif;?>
</tr>
<? endforeach;?>
</tbody>
</table>
<br>
<br>
</div>
</div>
<? endforeach;?>
</div>
<input type="hidden" name="count_checked" id="count_checked" value="<? echo $intCountChecked; ?>">
<br>
<font class="text"><?=GetMessage("FILENAME");?><br><br></font>
<input type="text" name="SETUP_FILE_NAME"
value="<?=htmlspecialcharsbx(strlen($SETUP_FILE_NAME) > 0 ?
$SETUP_FILE_NAME :
(COption::GetOptionString(
'catalog',
'export_default_path',
'/bitrix/catalog_export/'))
.'retailcrm'/* .mt_rand(0, 999999) */.'.xml'
); ?>" size="50">
<br>
<br>
<br>
<div id="profile-field" >
<font class="text"><?=GetMessage("OFFERS_VALUE") . ':';?>&nbsp<br><br></font>
<input
type="text"
name="MAX_OFFERS_VALUE"
value="<?= ($MAX_OFFERS_VALUE ? $MAX_OFFERS_VALUE: '');?>"
size="15">
<br>
<br>
<br>
</div>
<font class="text"><?=GetMessage("LOAD_PERIOD");?><br><br></font>
<input type="radio" name="TYPE_LOADING" value="none" onclick="checkProfile(this);"><?=GetMessage("NOT_LOADING");?><Br>
<input type="radio" name="TYPE_LOADING" value="cron" onclick="checkProfile(this);"><?=GetMessage("CRON_LOADING");?><Br>
<input type="radio" name="TYPE_LOADING" value="agent" checked onclick="checkProfile(this);"><?=GetMessage("AGENT_LOADING");?><Br>
<br>
<br>
<font class="text"><?=GetMessage("LOAD_NOW");?>&nbsp;</font>
<input id="load-now" onchange="checkLoadStatus(this)" type="checkbox" name="LOAD_NOW" value="now">
<br>
<div id="loadMessage" hidden><?=GetMessage("LOAD_NOW_MSG");?></div>
<br>
<font class="text"><?=GetMessage("BASE_PRICE");?>&nbsp;</font>
<select name="price-types" class="typeselect">
<option value=""></option>
<?php foreach($arResult['PRICE_TYPES'] as $priceType): ?>
<option value="<?php echo $priceType['ID']; ?>"
<?php if($priceType['BASE'] == 'Y') echo 'selected'; ?>>
<?php echo $priceType['NAME']; ?>
</option>
<?php endforeach; ?>
</select>
<br>
<br>
<br>
<div id="profile-field" >
<font class="text"><?=GetMessage("PROFILE_NAME");?>&nbsp;</font>
<input
type="text"
name="SETUP_PROFILE_NAME"
value="<?= ($SETUP_PROFILE_NAME ? $SETUP_PROFILE_NAME: GetMessage("PROFILE_NAME_EXAMPLE"));?>"
size="30">
<br>
<br>
<br>
</div>
<script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript">
function checkAll(obj,cnt)
{
for (i = 0; i < cnt; i++)
{
if (obj.checked)
BX.removeClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none");
}
var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE'));
if (obj.checked)
BX.removeClass(table,"iblock-export-table-display-none");
var easing = new BX.easing({
duration : 150,
start : {opacity : obj.checked ? 0 : 100 },
finish : {opacity: obj.checked ? 100 : 0 },
transition : BX.easing.transitions.linear,
step : function(state){
for (i = 0; i < cnt; i++)
{
BX('IBLOCK_EXPORT_TABLE'+(i+1)).style.opacity = state.opacity/100;
}
},
complete : function() {
for (i = 0; i < cnt; i++)
{
if (!obj.checked)
BX.addClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none");
}
}
});
easing.animate();
var boolCheck = obj.checked;
for (i = 0; i < cnt; i++)
{
BX('IBLOCK_EXPORT'+(i+1)).checked = boolCheck;
}
BX('count_checked').value = (boolCheck ? cnt : 0);
};
function checkOne(obj,cnt)
{
var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE'));
if (obj.checked)
BX.removeClass(table,"iblock-export-table-display-none");
var easing = new BX.easing({
duration : 150,
start : {opacity : obj.checked ? 0 : 100 },
finish : {opacity: obj.checked ? 100 : 0 },
transition : BX.easing.transitions.linear,
step : function(state){
table.style.opacity = state.opacity/100;
},
complete : function() {
if (!obj.checked)
BX.addClass(table,"iblock-export-table-display-none");
}
});
easing.animate();
var boolCheck = obj.checked;
var intCurrent = parseInt(BX('count_checked').value);
intCurrent += (boolCheck ? 1 : -1);
BX('icml_export_all').checked = (intCurrent < cnt ? false : true);
BX('count_checked').value = intCurrent;
};
function propertyChange(obj)
{
if (BX(obj.id).value !== 'none') {
if (obj.id.indexOf("SKU") !== -1) {
BX(obj.id.replace('SKU','PRODUCT')).value = 'none';
var bid = obj.id.replace('SKU','PRODUCT');
$("#" + bid).siblings('#highloadblock').remove();
} else if(BX(obj.id.replace('PRODUCT','SKU'))){
BX(obj.id.replace('PRODUCT','SKU')).value = 'none';
var bid = obj.id.replace('PRODUCT','SKU');
$("#" + bid).siblings('#highloadblock').remove();
}
}
if ($(obj).find('option')[obj.selectedIndex].className == 'not-highloadblock') {
var a = $(obj).find('option')[obj.selectedIndex].parent('select').siblings('#highloadblock');
$(a).remove();
}
if ($(obj).find('option')[obj.selectedIndex].className == 'highloadblock') {
getHbFromAjax($(obj).find('option')[obj.selectedIndex], 'sku');
}
if ($(obj).find('option')[obj.selectedIndex].className == 'highloadblock-product') {
getHbFromAjax($(obj).find('option')[obj.selectedIndex], 'product');
}
};
function checkLoadStatus(object)
{
if (object.checked) {
$('#loadMessage').show();
} else {
$('#loadMessage').hide();
}
}
function checkProfile(obj)
{
if (obj.value !== 'none')
$('#profile-field').show();
else
$('#profile-field').hide();
};
function getHbFromAjax(that, type) {
var url = $('td .adm-list-table-cell').parents('form').attr('action');
var td = $(that).parents('td .adm-list-table-cell');
var select = $(that).parent('select').siblings('#highloadblock');
var table_name = $(that).attr('id');
var iblock = $(that).parents('.IBLOCK_EXPORT_TABLE').attr('data-type');
var key = $(that).parent('select').attr('data-type');
var step = $('input[name="continue"]').val();
var id = $('input[name="id"]').val();
var install = $('input[name="install"]').val();
var sessid = BX.bitrix_sessid();
var data = 'install=' + install +'&step=' + step + '&sessid=' + sessid +
'&id=' + id + '&ajax=1&table=' + table_name;
$.ajax({
url: url,
type: 'POST',
data: data,
dataType: "json",
success: function(res) {
$(select).remove();
$('#waiting').remove();
var new_options = '';
$.each(res.fields, function(key, value) {
new_options += '<option value="' + value + '">' + value + '</option>';
});
if (type == 'sku') {
$(td).append('<select name="highloadblock' + res.table + '_' + key + '[' + iblock + ']" id="highloadblock" style="width: 100px; margin-left: 50px;">' + new_options + '</select>');
}
if (type == 'product') {
$(td).append('<select name="highloadblock_product' + res.table + '_' + key + '[' + iblock + ']" id="highloadblock" style="width: 100px; margin-left: 50px;">' + new_options + '</select>');
}
},
beforeSend: function() {
$(td).append('<span style="margin-left:50px;" id="waiting"><?=GetMessage("WAIT")?></span>');
}
});
}
</script>
<?//Следующие переменные должны быть обязательно установлены?>
<?=bitrix_sessid_post();?>
<input type="hidden" name="lang" value="<?php echo LANG; ?>">
<input type="hidden" name="id" value="intaro.retailcrm">
<input type="hidden" name="install" value="Y">
<input type="hidden" name="step" value="6">
<input type="hidden" name="continue" value="5">
<div style="padding: 1px 13px 2px; height:28px;">
<div align="right" style="float:right; width:50%; position:relative;">
<input type="submit" name="inst" onclick="BX.showWait()" value="<?= GetMessage("MOD_NEXT_STEP"); ?>"
class="adm-btn-save">
</div>
<div align="left" style="float:right; width:50%; position:relative;">
<input type="submit" name="back" value="<?= GetMessage("MOD_PREV_STEP"); ?>" class="adm-btn-save">
</div>
</div>
</form>

View File

@ -1,125 +0,0 @@
<?php
$MESS["CET_ERROR_NO_NAME"] = "Enter export profile name.";
$MESS["CET_STEP1"] = "Step";
$MESS["CET_STEP2"] = "of";
$MESS["CET_SAVE"] = "Save";
$MESS["CET_ERROR_NO_IBLOCK1"] = "Info block";
$MESS["CET_ERROR_NO_IBLOCK2"] = "not found.";
$MESS["CET_ERROR_NO_FILENAME"] = "Filename fpr export is not set.";
$MESS["CET_ERROR_NO_GROUPS"] = "Groups for export are not set.";
$MESS["CET_ERROR_NO_PROFILE_NAME"] = "Enter export profile name.";
$MESS["CET_SELECT_IBLOCK"] = "Select info block";
$MESS["CET_SELECT_IBLOCK_EXT"] = "Select info block for export:";
$MESS["CET_SELECT_GROUP"] = "Select groups:";
$MESS["CET_FIRST_SELECT_IBLOCK"] = "Select info block at first";
$MESS["CET_ALL_GROUPS"] = "All groups";
$MESS["CET_SERVER_NAME"] = "Domain name:";
$MESS["CET_SERVER_NAME_SET_CURRENT"] = "current";
$MESS["CET_SAVE_FILENAME"] = "Save to file:";
$MESS["CET_PROFILE_NAME"] = "Profile name:";
$MESS["CET_EXPORT"] = "Export";
$MESS["CET_ERROR_NO_IBLOCKS"] = "Info blocks for export are not set.";
$MESS["CET_EXPORT_CATALOGS"] = "Catalogs for export:";
$MESS["CET_CATALOG"] = "Catalog";
$MESS["CET_EXPORT2YANDEX"] = "Export to Yandex.Tovariy";
$MESS["CATI_DATA_EXPORT"] = "Data export";
$MESS["CATI_NO_IBLOCK"] = "Info block is not selected. Export is not possible.";
$MESS["CATI_NO_FORMAT"] = "Specify format of the data file and its properties.";
$MESS["CATI_NO_DELIMITER"] = "Specify the field delimiter character.";
$MESS["CATI_NO_SAVE_FILE"] = "Specify file for saving the result.";
$MESS["CATI_CANNOT_CREATE_FILE"] = "Error creating data file.";
$MESS["CATI_NO_FIELDS"] = "Fields for export are not set.";
$MESS["CATI_SCHEME_EXISTS"] = "Scheme with this name already exists.";
$MESS["CATI_PAGE_TITLE"] = "Catalog export: step";
$MESS["CATI_NEXT_STEP"] = "Next";
$MESS["CATI_INFOBLOCK"] = "Info block for export:";
$MESS["CATI_SCHEME_NAME"] = "Export scheme:";
$MESS["CATI_NOT"] = "No";
$MESS["CATI_DELETE"] = "delete";
$MESS["CATI_FIELDS"] = "Set correspondence of fields in file with fields in database";
$MESS["CATI_FI_ID"] = "ID";
$MESS["CATI_FI_NAME"] = "Name";
$MESS["CATI_FI_ACTIV"] = "Activity";
$MESS["CATI_FI_ACTIVFROM"] = "Active from";
$MESS["CATI_FI_ACTIVTO"] = "Active to";
$MESS["CATI_FI_CATIMG"] = "List image";
$MESS["CATI_FI_CATDESCR"] = "List description";
$MESS["CATI_FI_DETIMG"] = "Image";
$MESS["CATI_FI_DETDESCR"] = "Description";
$MESS["CATI_FI_UNIXML"] = "Unique id";
$MESS["CATI_FI_QUANT"] = "Quantity";
$MESS["CATI_FI_WEIGHT"] = "Weight";
$MESS["CATI_FI_PROPS"] = "Property";
$MESS["CATI_FI_GROUP_LEV"] = "Level group";
$MESS["CATI_FI_PRICE_TYPE"] = "Price type";
$MESS["CATI_FIELD"] = "field";
$MESS["CATI_FORMAT_PROPS"] = "Set file format properties";
$MESS["CATI_DELIMITERS"] = "With delimiters";
$MESS["CATI_DELIMITER_TYPE"] = "Delimiter type";
$MESS["CATI_TAB"] = "tab";
$MESS["CATI_TZP"] = "semicolon";
$MESS["CATI_ZPT"] = "comma";
$MESS["CATI_SPS"] = "space";
$MESS["CATI_OTR"] = "other";
$MESS["CATI_SAVE_SCHEME"] = "Save settings as scheme";
$MESS["CATI_SSCHEME_NAME"] = "Scheme name";
$MESS["CATI_DATA_FILE_NAME"] = "Save data file as...";
$MESS["CATI_DATA_FILE_NAME1"] = "Data file name";
$MESS["CATI_SUCCESS"] = "Export completed";
$MESS["CATI_SU_ALL"] = "Total raws exported:";
$MESS["CATI_BACK"] = "Back";
$MESS["CATI_FIRST_LINE_NAMES"] = "First line contains field names";
$MESS["CATI_SU_ALL1"] = "Download file DATA_URL on your computer";
$MESS["CATI_FIELDS_NEEDED"] = "To export";
$MESS["CATI_FIELDS_NAMES"] = "Filed name";
$MESS["CATI_FIELDS_SORTING"] = "Order";
$MESS["CATI_NEXT_STEP_F"] = "Start export";
$MESS["CATI_DATA_FILE_NAME1_DESC"] = "If such a file exists, it will be overwritten";
$MESS["CATI_TOO_MANY_TABLES"] = "The table joining is too large. Reduce the number of exported properties or price types.";
$MESS["EST_QUANTITY_FROM"] = "Purchased quantity from";
$MESS["EST_QUANTITY_TO"] = "Purchased quantity to";
$MESS["EST_PRICE_TYPE"] = "Price type \"#TYPE#\"";
$MESS["EST_PRICE_TYPE2"] = "Price type \"#NAME#\" (#TYPE#)";
$MESS["CAT_DETAIL_PROPS"] = "Detailed settings";
$MESS["CAT_DETAIL_PROPS_RUN"] = "configure";
$MESS["CET_IS_SKU"] = "Trade offers info block is chosen.";
$MESS["CET_USE_PARENT_SECT"] = "Use groups of products info block";
$MESS["CET_YAND_RUN_ERR_IBLOCK_ABSENT"] = "Info block ##IBLOCK_ID# not exists";
$MESS["CET_YAND_RUN_ERR_PRODUCT_IBLOCK_ABSENT"] = "Products info block ##IBLOCK_ID# not exists";
$MESS["CET_YAND_RUN_ERR_SECTION_SET_EMPTY"] = "Group list not set";
$MESS["CET_YAND_RUN_ERR_SETUP_FILE_ACCESS_DENIED"] = "No permission to re-write file #FILE#";
$MESS["CET_YAND_RUN_ERR_SETUP_FILE_OPEN_WRITING"] = "Unable to open file #FILE# for writing";
$MESS["CET_YAND_RUN_ERR_SETUP_FILE_WRITE"] = "Unable to write in file #FILE#";
$MESS["CET_YAND_SELECT_IBLOCK"] = "Info block for export";
$MESS["CET_SELECT_IBLOCK_TYPE"] = "Select info block type";
$MESS["CET_YAND_GROUP_AND_OFFERS"] = "Groups and products for import";
$MESS["CET_YAND_USE_IBLOCK_SITE"] = "Use domain name from info block";
$MESS["CET_ERROR_IBLOCK_PERM"] = "No permission to work with info block ##IBLOCK_ID#";
$MESS["YANDEX_ERR_SKU_SETTINGS_ABSENT"] = "Trade offers export settings are missing";
$MESS["CES_ERROR_BAD_EXPORT_FILENAME"] = "Export file name contains forbidden characters";
$MESS["CES_ERROR_BAD_EXPORT_FILENAME_EXTENTIONS"] = "Export file name contains forbidden extension";
$MESS["CES_ERROR_FORBIDDEN_EXPORT_FILENAME"] = "Forbidden export file name";
$MESS["CES_ERROR_PATH_WITHOUT_DEFAUT"] = "Export can only be made to the folder specified in the field <b>Default path for the exported files</b> in module settings.";
$MESS["CAT_ADM_CSV_EXP_TAB1"] = "Info block";
$MESS["CAT_ADM_CSV_EXP_TAB1_TITLE"] = "Select info block for export";
$MESS["CAT_ADM_CSV_EXP_TAB2"] = "Export parameters";
$MESS["CAT_ADM_CSV_EXP_TAB2_TITLE"] = "Export parameters settings";
$MESS["CAT_ADM_CSV_EXP_TAB3"] = "Result";
$MESS["CAT_ADM_CSV_EXP_TAB3_TITLE"] = "Export result";
$MESS["CAT_ADM_CSV_EXP_IBLOCK_ID"] = "Info block";
$MESS["CAT_ADM_CSV_EXP_ADD_SETTINGS"] = "Additional settings";
$MESS["CAT_ADM_CSV_EXP_EXPORT_FILES"] = "Export files";
$MESS["CAT_ADM_CSV_EXP_TIME_STEP"] = "Step execution time";
$MESS["CAT_ADM_CSV_EXP_TIME_STEP_COMMENT"] = "0 - load all at once<br>positive value - number of seconds to complete a single step";
$MESS["CAT_ADM_CSV_EXP_SEP_ELEMENTS"] = "Fields and properties of elements";
$MESS["CAT_ADM_CSV_EXP_SEP_SECTIONS"] = "Sections fields";
$MESS["CAT_ADM_CSV_EXP_SEP_SECTIONS_EXT"] = "Fields and custom properties of sections";
$MESS["CAT_ADM_CSV_EXP_SEP_PRODUCT"] = "Product properties";
$MESS["CAT_ADM_CSV_EXP_SEP_PRICES"] = "Prices";
$MESS["CAT_ADM_CSV_EXP_SEP_SKU"] = "Fields and properties of trade offers";
$MESS["CAT_ADM_CSV_EXP_DESCR_SECT_PROP"] = "Custom property";
$MESS["CAT_ADM_CSV_EXP_SECTION_LEVEL"] = "Level group #LEVEL#";
$MESS["CATI_FI_PRICE_TYPE2"] = "Price type \"#TYPE#\"";
$MESS["CATI_FI_PRICE_TYPE3"] = "Price type \"#NAME#\" (#TYPE#)";
$MESS["CATI_FI_PRICE_CURRENCY"] = "in currency #CURRENCY#";

View File

@ -9,8 +9,8 @@ $MESS["FILENAME"] = "Specify data file name:";
$MESS["LOAD_PURCHASE_PRICE"] = "Export purchase price"; $MESS["LOAD_PURCHASE_PRICE"] = "Export purchase price";
$MESS["PROPERTY"] = "Property that contains product article"; $MESS["PROPERTY"] = "Property that contains product article";
$MESS["ALL_CATALOG"] = "All catalogs"; $MESS["ALL_CATALOG"] = "All catalogs";
$MESS["CET_EXPORT"] = "Export"; $MESS["EXPORT"] = "Export";
$MESS["CET_SAVE"] = "Save"; $MESS["SAVE"] = "Save";
$MESS["ERROR_IBLOCK_MODULE"] = "Module Info blocks not installed"; $MESS["ERROR_IBLOCK_MODULE"] = "Module Info blocks not installed";
$MESS["ERROR_IBLOCK_CATALOG"] = "Module Catalog not installed"; $MESS["ERROR_IBLOCK_CATALOG"] = "Module Catalog not installed";
$MESS["ERROR_IBLOCK_INTAROCRM"] = "Module RetailCRM not installed"; $MESS["ERROR_IBLOCK_INTAROCRM"] = "Module RetailCRM not installed";

View File

@ -1,125 +0,0 @@
<?php
$MESS["CET_ERROR_NO_NAME"] = "Введите название профиля выгрузки.";
$MESS["CET_STEP1"] = "Шаг";
$MESS["CET_STEP2"] = "из";
$MESS["CET_SAVE"] = "Сохранить";
$MESS["CET_ERROR_NO_IBLOCK1"] = "Информационный блок";
$MESS["CET_ERROR_NO_IBLOCK2"] = "не найден.";
$MESS["CET_ERROR_NO_FILENAME"] = "Не указано имя файла для экспорта.";
$MESS["CET_ERROR_NO_GROUPS"] = "Не указаны выгружаемые группы.";
$MESS["CET_ERROR_NO_PROFILE_NAME"] = "Введите название профиля выгрузки.";
$MESS["CET_SELECT_IBLOCK"] = "Выберите инфоблок";
$MESS["CET_SELECT_IBLOCK_EXT"] = "Выберите инфоблок для экспорта:";
$MESS["CET_SELECT_GROUP"] = "Выберите группы:";
$MESS["CET_FIRST_SELECT_IBLOCK"] = "Сначала выберите информационный блок";
$MESS["CET_ALL_GROUPS"] = "Все группы";
$MESS["CET_SERVER_NAME"] = "Доменное имя:";
$MESS["CET_SERVER_NAME_SET_CURRENT"] = "текущее";
$MESS["CET_SAVE_FILENAME"] = "Сохранить в файл:";
$MESS["CET_PROFILE_NAME"] = "Имя профиля:";
$MESS["CET_EXPORT"] = "Экспортировать";
$MESS["CET_ERROR_NO_IBLOCKS"] = "Не указаны выгружаемые информационные блоки.";
$MESS["CET_EXPORT_CATALOGS"] = "Каталоги для экспорта:";
$MESS["CET_CATALOG"] = "Каталог";
$MESS["CET_EXPORT2YANDEX"] = "Экспортировать в Яндекс.Товары";
$MESS["CATI_DATA_EXPORT"] = "Экспорт данных";
$MESS["CATI_NO_IBLOCK"] = "Информационный блок не выбран. Выгрузка невозможна.";
$MESS["CATI_NO_FORMAT"] = "Укажите формат файла данных и его свойства.";
$MESS["CATI_NO_DELIMITER"] = "Укажите символ-разделитель полей.";
$MESS["CATI_NO_SAVE_FILE"] = "Укажите файл для сохранения результата.";
$MESS["CATI_CANNOT_CREATE_FILE"] = "Ошибка создания файла данных.";
$MESS["CATI_NO_FIELDS"] = "Не заданы поля для экспорта.";
$MESS["CATI_SCHEME_EXISTS"] = "Схема с таким именем уже существует.";
$MESS["CATI_PAGE_TITLE"] = "Выгрузка каталога: шаг";
$MESS["CATI_NEXT_STEP"] = "Далее";
$MESS["CATI_INFOBLOCK"] = "Информационный блок для экспорта:";
$MESS["CATI_SCHEME_NAME"] = "Схема выгрузки:";
$MESS["CATI_NOT"] = "Нет";
$MESS["CATI_DELETE"] = "удалить";
$MESS["CATI_FIELDS"] = "Задайте соответствие полей в файле полям в базе";
$MESS["CATI_FI_ID"] = "Идентификатор";
$MESS["CATI_FI_NAME"] = "Название";
$MESS["CATI_FI_ACTIV"] = "Активность";
$MESS["CATI_FI_ACTIVFROM"] = "Активность с";
$MESS["CATI_FI_ACTIVTO"] = "Активность до";
$MESS["CATI_FI_CATIMG"] = "Картинка для списка";
$MESS["CATI_FI_CATDESCR"] = "Описание для списка";
$MESS["CATI_FI_DETIMG"] = "Картинка";
$MESS["CATI_FI_DETDESCR"] = "Описание";
$MESS["CATI_FI_UNIXML"] = "Уникальный идентификатор";
$MESS["CATI_FI_QUANT"] = "Количество";
$MESS["CATI_FI_WEIGHT"] = "Вес";
$MESS["CATI_FI_PROPS"] = "Свойство";
$MESS["CATI_FI_GROUP_LEV"] = "Группа уровня";
$MESS["CATI_FI_PRICE_TYPE"] = "Цена типа";
$MESS["CATI_FIELD"] = "поле";
$MESS["CATI_FORMAT_PROPS"] = "Задайте свойства формата файла";
$MESS["CATI_DELIMITERS"] = "С разделителями";
$MESS["CATI_DELIMITER_TYPE"] = "Разделитель полей";
$MESS["CATI_TAB"] = "табуляция";
$MESS["CATI_TZP"] = "точка с запятой";
$MESS["CATI_ZPT"] = "запятая";
$MESS["CATI_SPS"] = "пробел";
$MESS["CATI_OTR"] = "другой";
$MESS["CATI_SAVE_SCHEME"] = "Сохранить настройки как схему";
$MESS["CATI_SSCHEME_NAME"] = "Имя схемы";
$MESS["CATI_DATA_FILE_NAME"] = "Сохранить файл данных как...";
$MESS["CATI_DATA_FILE_NAME1"] = "Имя файла данных";
$MESS["CATI_SUCCESS"] = "Выгрузка завершена";
$MESS["CATI_SU_ALL"] = "Всего выгружено строк:";
$MESS["CATI_BACK"] = "Назад";
$MESS["CATI_FIRST_LINE_NAMES"] = "Первая строка содержит имена полей";
$MESS["CATI_SU_ALL1"] = "Скачать файл %DATA_URL% на свой компьютер";
$MESS["CATI_FIELDS_NEEDED"] = "Выгружать";
$MESS["CATI_FIELDS_NAMES"] = "Название поля";
$MESS["CATI_FIELDS_SORTING"] = "Порядок";
$MESS["CATI_NEXT_STEP_F"] = "Начать выгрузку";
$MESS["CATI_DATA_FILE_NAME1_DESC"] = "Если такой файл существует, то он будет перезаписан";
$MESS["CATI_TOO_MANY_TABLES"] = "Слишком большое объединение таблиц. Уменьшите количество экспортируемых свойств или типов цен.";
$MESS["EST_QUANTITY_FROM"] = "Покупаемое количество от";
$MESS["EST_QUANTITY_TO"] = "Покупаемое количество до";
$MESS["EST_PRICE_TYPE"] = "Тип цен \"#TYPE#\"";
$MESS["EST_PRICE_TYPE2"] = "Тип цен \"#NAME#\" (#TYPE#)";
$MESS["CAT_DETAIL_PROPS"] = "Детальные настройки";
$MESS["CAT_DETAIL_PROPS_RUN"] = "настроить";
$MESS["CET_IS_SKU"] = "Выбран инфоблок торговых предложений.";
$MESS["CET_USE_PARENT_SECT"] = "Использовать группы инфоблока товаров";
$MESS["CET_YAND_RUN_ERR_IBLOCK_ABSENT"] = "Инфоблок ##IBLOCK_ID# не существует";
$MESS["CET_YAND_RUN_ERR_PRODUCT_IBLOCK_ABSENT"] = "Инфоблок товаров ##IBLOCK_ID# не существует";
$MESS["CET_YAND_RUN_ERR_SECTION_SET_EMPTY"] = "Список групп не задан";
$MESS["CET_YAND_RUN_ERR_SETUP_FILE_ACCESS_DENIED"] = "Недостаточно прав для перезаписи файла #FILE#";
$MESS["CET_YAND_RUN_ERR_SETUP_FILE_OPEN_WRITING"] = "Невозможно открыть файл #FILE# для записи";
$MESS["CET_YAND_RUN_ERR_SETUP_FILE_WRITE"] = "Запись в файл #FILE# невозможна";
$MESS["CET_YAND_SELECT_IBLOCK"] = "Инфоблок для экспорта";
$MESS["CET_SELECT_IBLOCK_TYPE"] = "Выберите тип инфоблока";
$MESS["CET_YAND_GROUP_AND_OFFERS"] = "Группы и товары для импорта";
$MESS["CET_YAND_USE_IBLOCK_SITE"] = "Брать доменное имя из инфоблока";
$MESS["CET_ERROR_IBLOCK_PERM"] = "Недостаточно прав для работы с инфоблоком ##IBLOCK_ID#";
$MESS["YANDEX_ERR_SKU_SETTINGS_ABSENT"] = "Отсутствуют настройки экспорта торговых предложений";
$MESS["CES_ERROR_BAD_EXPORT_FILENAME"] = "Имя файла экспорта содержит запрещенные символы";
$MESS["CES_ERROR_BAD_EXPORT_FILENAME_EXTENTIONS"] = "Имя файла экспорта содержит запрещенное расширение";
$MESS["CES_ERROR_FORBIDDEN_EXPORT_FILENAME"] = "Запрещенное имя файла экспорта";
$MESS["CES_ERROR_PATH_WITHOUT_DEFAUT"] = "Экспорт может быть осуществлён только в папку, указанную в поле <b>Путь по умолчанию для экспортируемых файлов</b> настроек модуля.";
$MESS["CAT_ADM_CSV_EXP_TAB1"] = "Инфоблок";
$MESS["CAT_ADM_CSV_EXP_TAB1_TITLE"] = "Выбор информационного блока для экспорта";
$MESS["CAT_ADM_CSV_EXP_TAB2"] = "Параметры экспорта";
$MESS["CAT_ADM_CSV_EXP_TAB2_TITLE"] = "Настройка параметров экспорта";
$MESS["CAT_ADM_CSV_EXP_TAB3"] = "Результат";
$MESS["CAT_ADM_CSV_EXP_TAB3_TITLE"] = "Результат экспорта";
$MESS["CAT_ADM_CSV_EXP_IBLOCK_ID"] = "Инфоблок";
$MESS["CAT_ADM_CSV_EXP_ADD_SETTINGS"] = "Дополнительные настройки";
$MESS["CAT_ADM_CSV_EXP_EXPORT_FILES"] = "Выгружать файлы";
$MESS["CAT_ADM_CSV_EXP_TIME_STEP"] = "Время выполнения шага";
$MESS["CAT_ADM_CSV_EXP_TIME_STEP_COMMENT"] = "0 - загрузить все сразу<br>положительное значение - число секунд на выполнение одного шага";
$MESS["CAT_ADM_CSV_EXP_SEP_ELEMENTS"] = "Поля и свойства элементов";
$MESS["CAT_ADM_CSV_EXP_SEP_SECTIONS"] = "Поля разделов";
$MESS["CAT_ADM_CSV_EXP_SEP_SECTIONS_EXT"] = "Поля и пользовательские свойства разделов";
$MESS["CAT_ADM_CSV_EXP_SEP_PRODUCT"] = "Свойства товара";
$MESS["CAT_ADM_CSV_EXP_SEP_PRICES"] = "Цены";
$MESS["CAT_ADM_CSV_EXP_SEP_SKU"] = "Поля и свойства торговых предложений";
$MESS["CAT_ADM_CSV_EXP_DESCR_SECT_PROP"] = "Пользовательское свойство";
$MESS["CAT_ADM_CSV_EXP_SECTION_LEVEL"] = "Раздел уровня #LEVEL#";
$MESS["CATI_FI_PRICE_TYPE2"] = "Цена типа \"#TYPE#\"";
$MESS["CATI_FI_PRICE_TYPE3"] = "Цена типа \"#NAME#\" (#TYPE#)";
$MESS["CATI_FI_PRICE_CURRENCY"] = "в валюте #CURRENCY#";

View File

@ -1,4 +1,4 @@
<? <?php
$MESS["ERROR_FILENAME_NOT_SET"] = "Не указан файл данных."; $MESS["ERROR_FILENAME_NOT_SET"] = "Не указан файл данных.";
$MESS["ERROR_PROFIE_NOT_SET"] = "Не указано имя профиля"; $MESS["ERROR_PROFIE_NOT_SET"] = "Не указано имя профиля";
@ -9,8 +9,8 @@ $MESS["FILENAME"] = "Укажите имя файла данных:";
$MESS["LOAD_PURCHASE_PRICE"] = "Выгружать закупочную цену"; $MESS["LOAD_PURCHASE_PRICE"] = "Выгружать закупочную цену";
$MESS["PROPERTY"] = "Свойство, содержащее артикул товара"; $MESS["PROPERTY"] = "Свойство, содержащее артикул товара";
$MESS["ALL_CATALOG"] = "Все каталоги"; $MESS["ALL_CATALOG"] = "Все каталоги";
$MESS["CET_EXPORT"] = "Экспортировать"; $MESS["EXPORT"] = "Экспортировать";
$MESS["CET_SAVE"] = "Сохранить"; $MESS["SAVE"] = "Сохранить";
$MESS["ERROR_IBLOCK_MODULE"] = "Модуль Инфоблоки не установлен"; $MESS["ERROR_IBLOCK_MODULE"] = "Модуль Инфоблоки не установлен";
$MESS["ERROR_IBLOCK_CATALOG"] = "Модуль Каталог не установлен"; $MESS["ERROR_IBLOCK_CATALOG"] = "Модуль Каталог не установлен";
$MESS["ERROR_IBLOCK_INTAROCRM"] = "Модуль RetailCRM не установлен"; $MESS["ERROR_IBLOCK_INTAROCRM"] = "Модуль RetailCRM не установлен";

View File

@ -0,0 +1,50 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Controller\Loyalty
* @author RetailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Controller;
use Bitrix\Main\Engine\Controller;
use CModule;
use Intaro\RetailCrm\Service\Hl;
/**
* Class Order
*
* @package Intaro\RetailCrm\Controller\Loyalty
*/
class Icml extends Controller
{
/**
* @param string|null $tableName
*
* @return array
*/
public function getHlTableAction(?string $tableName): array
{
$hlBlockList = [];
CModule::IncludeModule('highloadblock');
$entity = Hl::getBaseEntityByTableName($tableName ?? null);
if ($entity) {
$hbFields = $entity->getFields();
$hlBlockList['table'] = $entity->getDBTableName();
foreach ($hbFields as $hbFieldCode => $hbField) {
$hlBlockList['fields'][] = $hbFieldCode;
}
return $hlBlockList;
}
}
}

View File

@ -182,6 +182,7 @@ class IcmlDirector
$this->setup->properties->sku->names[$productIblockId], $this->setup->properties->sku->names[$productIblockId],
$this->setup->basePriceId $this->setup->basePriceId
); );
$this->writeOffersAsOffersInXml($paramsForProduct, $paramsForOffer, $catalogIblockInfo); $this->writeOffersAsOffersInXml($paramsForProduct, $paramsForOffer, $catalogIblockInfo);
} }

View File

@ -0,0 +1,714 @@
<?php
namespace Intaro\RetailCrm\Icml;
use Bitrix\Highloadblock\HighloadBlockTable;
use CCatalog;
use CCatalogGroup;
use CCatalogSku;
use CIBlock;
use Intaro\RetailCrm\Service\Hl;
use RetailcrmConfigProvider;
/**
* Отвечает за управление настройками выгрузки icml каталога
*
* Class SettingsService
*
* @package Intaro\RetailCrm\Icml
*/
class SettingsService
{
/**
* инфоблок товаров, имеющих торговые предложения,
* при это сам инфоблок тоже является торговым каталогом
*/
public const CATALOG_WITH_SKU = 'X';
/*
* инфоблок товаров, имеющих торговые предложения,
* но сам торговым каталогом не является
*/
public const INFOBLOCK_WITH_SKU = 'P';
/**
* @var array
*/
private $arOldSetupVars;
/**
* @var string|null
*/
private $action;
/**
* @var mixed|string|null
*/
public $iblockExport;
/**
* @var mixed|string|null
*/
public $loadPurchasePrice;
/**
* @var array
*/
public $iblockPropertySku = [];
/**
* @var array
*/
public $iblockPropertyUnitSku = [];
/**
* @var array
*/
public $iblockPropertyProduct = [];
/**
* @var array
*/
public $iblockPropertyUnitProduct = [];
/**
* @var string
*/
public $setupFileName = '';
/**
* @var string
*/
public $setupProfileName = '';
/**
* @var array
*/
public $priceTypes = [];
/**
* @var \Intaro\RetailCrm\Icml\SettingsService|null
*/
private static $instance = null;
/**
* SettingsService constructor.
*
* @param array $arOldSetupVars
* @param string|null $action
*/
private function __construct(array $arOldSetupVars, ?string $action)
{
$this->arOldSetupVars = $arOldSetupVars;
$this->action = $action;
$this->iblockExport = $this->getSingleSetting('iblockExport');
$this->loadPurchasePrice = $this->getSingleSetting('loadPurchasePrice');
$oldSetup = $this->getSingleSetting('SETUP_FILE_NAME');
$defaultFilePath = RetailcrmConfigProvider::getDefaultIcmlPath();
$this->setupFileName = htmlspecialcharsbx($oldSetup ?? $defaultFilePath);
$this->setupProfileName
= $this->getSingleSetting('SETUP_PROFILE_NAME') ?? GetMessage('PROFILE_NAME_EXAMPLE');
$this->getPriceTypes();
}
/**
* @param array $arOldSetupVars
* @param string|null $action
*
* @return \Intaro\RetailCrm\Icml\SettingsService|null
*/
static public function getInstance(array $arOldSetupVars, ?string $action): ?SettingsService
{
if(is_null(self::$instance))
{
self::$instance = new self($arOldSetupVars, $action);
}
return self::$instance;
}
public function getPriceTypes()
{
$dbPriceType = CCatalogGroup::GetList(['SORT' => 'ASC'], [], [], [], ['ID', 'NAME', 'BASE']);
while ($arPriceType = $dbPriceType->Fetch()) {
$this->priceTypes[$arPriceType['ID']] = $arPriceType;
}
}
/**
* @param string $selected
* @param string $key
* @param int $iblockId
* @param string $field
* @param string $fieldGroup
*
* @return string
*/
public function getHlOptionStatus(string $selected, string $key, int $iblockId, string $field, string $fieldGroup): string
{
if ($this->arOldSetupVars[$fieldGroup . $selected . '_' . $key][$iblockId] === $field) {
return ' selected';
}
return '';
}
/**
* @param string $key
* @param int $iblockId
* @param string $tableName
* @param string $catalogType
*
* @return bool
*/
public function isHlSelected(
string $key,
int $iblockId,
string $tableName = '',
string $catalogType = ''
): bool {
return isset(
$tableName,
$this->arOldSetupVars['highloadblock' . $catalogType . $tableName . '_' .$key][$iblockId]
);
}
/**
* @param string $key
*
* @return bool
*/
public function isOptionHasPreset(string $key): bool
{
return version_compare(SM_VERSION, '14.0.0', '>=')
&& array_key_exists($key, $this->getIblockFieldsNames());
}
/**
* @return bool
*/
public function isSetupModulePage(): bool
{
global $APPLICATION;
return $APPLICATION->GetCurPage() === '/bitrix/admin/partner_modules.php';
}
/**
* @param array $properties
* @param string $propName
*/
private function setProperties(array &$properties, string $propName): void
{
foreach ($this->arOldSetupVars[$propName] as $iblock => $val) {
$properties[$iblock][$propName] = $val;
}
}
/**
* @return mixed|string
*/
public function getSingleSetting(string $settingName)
{
return $this->arOldSetupVars[$settingName] ?? null;
}
/**
* @return string[]
*/
public function getIblockPropsPreset(): array
{
return [
'article' => 'article',
'manufacturer' => 'manufacturer',
'color' => 'color',
'size' => 'size',
'weight' => 'weight',
'length' => 'length',
'width' => 'width',
'height' => 'height',
'picture' => 'picture',
];
}
/**
* @return array
*/
public function getHintProps(): array
{
return [
'article' => ['ARTICLE', 'ART', 'ARTNUMBER', 'ARTICUL', 'ARTIKUL'],
'manufacturer' => ['MANUFACTURER', 'PROISVODITEL', 'PROISVOD', 'PROISV'],
'color' => ['COLOR', 'CVET'],
'size' => ['SIZE', 'RAZMER'],
'weight' => ['WEIGHT', 'VES', 'VEC'],
'length' => ['LENGTH', 'DLINA'],
'width' => ['WIDTH', 'SHIRINA'],
'height' => ['HEIGHT', 'VISOTA'],
'picture' => ['PICTURE', 'PICTURE'],
];
}
/**
* @return array
*/
public function getIblockPropsNames(): array
{
return [
'article' => GetMessage('PROPERTY_ARTICLE_HEADER_NAME'),
'manufacturer' => GetMessage('PROPERTY_MANUFACTURER_HEADER_NAME'),
'color' => GetMessage('PROPERTY_COLOR_HEADER_NAME'),
'size' => GetMessage('PROPERTY_SIZE_HEADER_NAME'),
'weight' => GetMessage('PROPERTY_WEIGHT_HEADER_NAME'),
'length' => GetMessage('PROPERTY_LENGTH_HEADER_NAME'),
'width' => GetMessage('PROPERTY_WIDTH_HEADER_NAME'),
'height' => GetMessage('PROPERTY_HEIGHT_HEADER_NAME'),
'picture' => GetMessage('PROPERTY_PICTURE_HEADER_NAME'),
];
}
/**
* @return array[]
*/
public function getIblockFieldsNames(): array
{
return [
'weight' => [
'CODE' => 'catalog_weight',
'name' => GetMessage('SELECT_WEIGHT_PROPERTY_NAME'),
'unit' => 'mass',
],
'length' => [
'CODE' => 'catalog_length',
'name' => GetMessage('SELECT_LENGTH_PROPERTY_NAME'),
'unit' => 'length',
],
'width' => [
'CODE' => 'catalog_width',
'name' => GetMessage('SELECT_WIDTH_PROPERTY_NAME'),
'unit' => 'length',
],
'height' => [
'CODE' => 'catalog_height',
'name' => GetMessage('SELECT_HEIGHT_PROPERTY_NAME'),
'unit' => 'length',
],
];
}
/**
* @return array[]
*/
public function getUnitsNames(): array
{
return [
'length' => [
'mm' => GetMessage('UNIT_MEASUREMENT_MM'),
'cm' => GetMessage('UNIT_MEASUREMENT_CM'),
'm' => GetMessage('UNIT_MEASUREMENT_M'),
],
'mass' => [
'mg' => GetMessage('UNIT_MEASUREMENT_MG'),
'g' => GetMessage('UNIT_MEASUREMENT_G'),
'kg' => GetMessage('UNIT_MEASUREMENT_KG'),
],
];
}
/**
* @return string[]
*/
public function getHintUnit(): array
{
return [
'length' => 'mm',
'mass' => 'g',
];
}
public function setProps(): void
{
foreach ($this->getIblockPropsPreset() as $prop) {
$this->setProperties($this->iblockPropertySku, 'iblockPropertySku_' . $prop);
$this->setProperties($this->iblockPropertyUnitSku, 'iblockPropertyUnitSku_' . $prop);
$this->setProperties($this->iblockPropertyProduct, 'iblockPropertyProduct_' . $prop);
$this->setProperties($this->iblockPropertyUnitProduct, 'iblockPropertyUnitProduct_' . $prop);
}
}
/**
* @param string|null $setupFileName
* @param string $setupProfileName
*
* @return array
*/
private function checkFileAndProfile(?string $setupFileName, string $setupProfileName): array
{
global $APPLICATION;
$arSetupErrors = [];
if (strlen($setupFileName) <= 0) {
$arSetupErrors[] = GetMessage('ERROR_NO_FILENAME');
} elseif ($APPLICATION->GetFileAccessPermission($setupFileName) < 'W') {
$arSetupErrors[] = str_replace('#FILE#', $setupFileName,
GetMessage('FILE_ACCESS_DENIED'));
}
$isValidAction = (
$this->action === 'EXPORT_SETUP'
|| $this->action === 'EXPORT_EDIT'
|| $this->action === 'EXPORT_COPY'
);
if ($isValidAction && strlen($setupProfileName) <= 0) {
$arSetupErrors[] = GetMessage('ERROR_NO_PROFILE_NAME');
}
return $arSetupErrors;
}
/**
* @return array
* @throws \Bitrix\Main\ArgumentException
* @throws \Bitrix\Main\LoaderException
* @throws \Bitrix\Main\ObjectPropertyException
* @throws \Bitrix\Main\SystemException
*/
public function getHlBlockList(): array
{
$hlBlockList = [];
$hlblockListDb = HighloadBlockTable::getList();
while ($hlblockArr = $hlblockListDb->Fetch()) {
$entity = Hl::getBaseEntityByHlId($hlblockArr['ID']);
$hbFields = $entity->getFields();
$hlBlockList[$hlblockArr['TABLE_NAME']]['LABEL'] = $hlblockArr['NAME'];
foreach ($hbFields as $hbFieldCode => $hbField) {
$hlBlockList[$hlblockArr['TABLE_NAME']]['FIELDS'][] = $hbFieldCode;
}
}
return $hlBlockList;
}
/**
* @param array $iblockProperties
* @param bool $hlblockModule
* @param array $hlBlockList
*
* @return string
*/
public function getSetupFieldsString(array $iblockProperties, bool $hlblockModule, array $hlBlockList): string
{
$values = 'loadPurchasePrice,SETUP_FILE_NAME,iblockExport,maxOffersValue';
foreach ($iblockProperties as $val) {
$values .= ',iblockPropertySku_' . $val
. ',iblockPropertyUnitSku_' . $val
. ',iblockPropertyProduct_' . $val
. ',iblockPropertyUnitProduct_' . $val;
if ($hlblockModule === true && $val !== 'picture') {
foreach ($hlBlockList as $hlblockTable => $hlblock) {
$values .= ',highloadblock' . $hlblockTable . '_' . $val;
$values .= ',highloadblock_product' . $hlblockTable . '_' . $val;
}
}
}
return $values;
}
/**
* @param array $prop
*
* @return string|null
*/
public function getHlTableName(array $prop): ?string
{
if ($prop['USER_TYPE'] === 'directory') {
return $prop['USER_TYPE_SETTINGS']['TABLE_NAME'];
}
return null;
}
/**
* @param array $prop
* @param array|null $oldSelect
* @param string $key
*
* @return bool
*/
public function isOptionSelected(array $prop, array $oldSelect, string $key): bool
{
if (count($oldSelect) > 0) {
if ($prop['CODE'] === $oldSelect[$key]) {
return true;
}
} else {
$iblockPropertiesHint = $this->getHintProps();
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($prop['CODE'] === $hint) {
return true;
}
}
}
return false;
}
/**
* @param array $prop
* @param bool $isProduct
*
* @return string
*/
public function getOptionClass(array $prop, bool $isProduct): string
{
$productMarker = $isProduct ? '-product' : '';
if ($prop['USER_TYPE'] === 'directory') {
return 'class="highloadblock' . $productMarker .'" id="'
. $prop['USER_TYPE_SETTINGS']['TABLE_NAME']
. '"';
}
return 'class="not-highloadblock"';
}
/**
* @param array $unitSelect
* @param string|null $keyUnit
* @param string|null $key
* @param string|null $unitTypeName
*
* @return string
*/
public function getUnitOptionStatus(array $unitSelect, ?string $keyUnit, ?string $key, ?string $unitTypeName): string
{
if (count($unitSelect) > 0) {
if ($keyUnit === $unitSelect[$key]) {
return ' selected';
}
} else {
$hintUnit = $this->getHintUnit();
if ($keyUnit === $hintUnit[$unitTypeName]) {
return ' selected';
}
}
return '';
}
/**
* @param int $iblockId
*
* @return array
*/
public function getSiteList(int $iblockId): array
{
$siteList = [];
$rsSites = CIBlock::GetSite($iblockId);
while ($arSite = $rsSites->Fetch()) {
$siteList[] = $arSite['SITE_ID'];
}
return $siteList;
}
/**
* @param int $iblockId
*
* @return array|null
*/
private function getSkuProps(int $iblockId): ?array
{
$propertiesSKU = null;
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblockId);
if ($iblockOffer !== false) {
$dbSkuProperties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], []);
while ($prop = $dbSkuProperties->Fetch()) {
$propertiesSKU[] = $prop;
}
}
return $propertiesSKU;
}
/**
* Возвращает уже выбранные свойства
*
* @param array|null $oldValues
* @param int $iblockId
* @param string $keyGroup
*
* @return array
*/
private function getOldProps(?array $oldValues, int $iblockId, string $keyGroup = ''): array
{
$props = [];
if (isset($oldValues[$iblockId])) {
foreach ($this->getIblockPropsNames() as $key => $prop) {
$fullKey = $keyGroup . '_' . $key;
$props[$key] = $oldValues[$iblockId][$fullKey];
}
}
return $props;
}
/**
* @param array $arCatalog
*
* @return bool
*/
private function isCorrectCatalogType(array $arCatalog): bool
{
return $arCatalog['CATALOG_TYPE'] === 'D'
|| $arCatalog['CATALOG_TYPE'] === 'X'
|| $arCatalog['CATALOG_TYPE'] === 'P';
}
/**
* @param int $iblockId
*
* @return array
*/
public function getProductProps(int $iblockId): array
{
$propertiesProduct = null;
$iblockResult = CIBlock::GetProperties($iblockId, []);
while ($prop = $iblockResult->Fetch()) {
$propertiesProduct[] = $prop;
}
return $propertiesProduct;
}
/**
* @param $iblockId
* @param $iblockExport
*
* @return bool
*/
public function isExport($iblockId, $iblockExport): bool
{
if (count($iblockExport) !== 0) {
return (in_array($iblockId, $iblockExport));
}
return true;
}
/**
* @param int $step
* @param string|null $fileName
* @param string|null $profileName
*
* @return int
*/
public function returnIfErrors(int $step, ?string $fileName, ?string $profileName): int
{
if ($step === 2) {
$arSetupErrors = $this->checkFileAndProfile(
$fileName ?? null,
$profileName ?? null
);
if (count($arSetupErrors) > 0) {
ShowError(implode('<br />', $arSetupErrors));
return 1;
}
}
return $step;
}
/**
* @return array
*/
public function getSettingsForIblocks(): array
{
$arIBlockList = [];
$intCountChecked = 0;
$intCountAvailIBlock = 0;
$dbRes = CIBlock::GetList(
['IBLOCK_TYPE' => 'ASC', 'NAME' => 'ASC'],
['CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'W']
);
while ($iblock = $dbRes->Fetch()) {
$arCatalog = CCatalog::GetByIDExt($iblock['ID']);
if (!$arCatalog || !$this->isCorrectCatalogType($arCatalog)) {
continue;
}
if (
$arCatalog['CATALOG_TYPE'] === self::CATALOG_WITH_SKU
|| $arCatalog['CATALOG_TYPE'] === self::INFOBLOCK_WITH_SKU
) {
$propertiesSKU = $this->getSkuProps($iblock['ID']);
$oldPropertySKU = $this->getOldProps(
$this->iblockPropertySku,
$iblock['ID'],
'iblockPropertySku'
);
$oldPropertyUnitSKU = $this->getOldProps(
$this->iblockPropertyUnitSku,
$iblock['ID'],
'iblockPropertyUnitSku'
);
}
$arIBlockList[] = [
'ID' => $iblock['ID'],
'NAME' => $iblock['NAME'],
'IBLOCK_TYPE_ID' => $iblock['IBLOCK_TYPE_ID'],
'iblockExport' => $this->isExport($iblock['ID'], $this->iblockExport),
'PROPERTIES_SKU' => $propertiesSKU ?? null,
'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU ?? [],
'OLD_PROPERTY_UNIT_SKU_SELECT' => $oldPropertyUnitSKU ?? [],
'PROPERTIES_PRODUCT' => $this->getProductProps($iblock['ID']),
'OLD_PROPERTY_PRODUCT_SELECT' => $this->getOldProps(
$this->iblockPropertyProduct,
$iblock['ID'],
'iblockPropertyProduct'
),
'OLD_PROPERTY_UNIT_PRODUCT_SELECT' => $this->getOldProps(
$this->iblockPropertyUnitProduct,
$iblock['ID'],
'iblockPropertyUnitProduct'
),
'SITE_LIST' => '(' . implode(' ', $this->getSiteList($iblock['ID'])) . ')',
];
if ($arIBlockList['iblockExport']) {
$intCountChecked++;
}
$intCountAvailIBlock++;
unset($propertiesSKU, $oldPropertySKU, $oldPropertyUnitSKU);
}
return [$arIBlockList, $intCountChecked, $intCountAvailIBlock, $arIBlockList['iblockExport'] ?? false];
}
}

View File

@ -106,7 +106,7 @@ class XmlOfferDirector
{ {
foreach ($xmlOffers as $offer) { foreach ($xmlOffers as $offer) {
$offer->productId = $product->id; $offer->productId = $product->id;
$offer->params = array_merge($offer->params, $product->params); $offer->params = $this->mergeParams($offer->params, $product->params);
$offer->unitCode = $offer->unitCode === null ? null : $offer->unitCode->merge($product->unitCode); $offer->unitCode = $offer->unitCode === null ? null : $offer->unitCode->merge($product->unitCode);
$offer->vatRate = $offer->vatRate === 'none' ? $product->vatRate : $offer->vatRate; $offer->vatRate = $offer->vatRate === 'none' ? $product->vatRate : $offer->vatRate;
$offer->vendor = $offer->mergeValues($product->vendor, $offer->vendor); $offer->vendor = $offer->mergeValues($product->vendor, $offer->vendor);
@ -203,4 +203,29 @@ class XmlOfferDirector
->getProductPicture($product, $pictureProperty ?? '') ->getProductPicture($product, $pictureProperty ?? '')
); );
} }
/**
* @param array $offerParams
* @param array $productParams
*/
private function mergeParams(array $offerParams, array $productParams): array
{
$offerCodes = [];
/** @var \Intaro\RetailCrm\Model\Bitrix\Xml\OfferParam $offerParam */
foreach ($offerParams as $offerParam) {
$offerCodes[] = $offerParam->code;
}
/** @var \Intaro\RetailCrm\Model\Bitrix\Xml\OfferParam $productParam */
foreach ($productParams as $productParam) {
if (in_array($productParam->code, $offerCodes, true)) {
continue;
}
$offerParams[] = $productParam;
}
return $offerParams;
}
} }

View File

@ -0,0 +1,48 @@
<?php
$MESS["ERROR_FILENAME_NOT_SET"] = "Data file not set.";
$MESS["ERROR_PROFIE_NOT_SET"] = "Profile name not set";
$MESS["EXPORT_CATALOGS"] = "Select catalogs for export to ICML:";
$MESS["CATALOG"] = "Catalog";
$MESS["EXPORT2INTAROCML"] = "Export to ICML";
$MESS["FILENAME"] = "Specify data file name:";
$MESS["LOAD_PURCHASE_PRICE"] = "Export purchase price";
$MESS["PROPERTY"] = "Property that contains product article";
$MESS["ALL_CATALOG"] = "All catalogs";
$MESS["EXPORT"] = "Export";
$MESS["SAVE"] = "Save";
$MESS["ERROR_IBLOCK_MODULE"] = "Module Info blocks not installed";
$MESS["ERROR_IBLOCK_CATALOG"] = "Module Catalog not installed";
$MESS["ERROR_IBLOCK_INTAROCRM"] = "Module RetailCRM not installed";
$MESS["ERROR_ARTICLE_NOT_SET"] = "Article fields were set, but Info blocks were not installed";
$MESS["PROFILE_NAME"] = "Profile name";
$MESS["SETTINGS_INFOBLOCK"] = "Info block settings";
$MESS["SETTINGS_EXPORT"] = "Export settings";
$MESS["CHECK_ALL_INFOBLOCKS"] = "Select all info blocks ";
$MESS["LOADED_PROPERTY"] = "Exported property";
$MESS["PROPERTY_PRODUCT_HEADER_NAME"] = "Product property";
$MESS["PROPERTY_OFFER_HEADER_NAME"] = "Trade offer property";
$MESS["PROPERTY_ARTICLE_HEADER_NAME"] = "Article";
$MESS["PROPERTY_MANUFACTURER_HEADER_NAME"] = "Manufacturer";
$MESS["PROPERTY_COLOR_HEADER_NAME"] = "Color";
$MESS["PROPERTY_WEIGHT_HEADER_NAME"] = "Weight (dimensions)";
$MESS["PROPERTY_LENGTH_HEADER_NAME"] = "Length (dimensions)";
$MESS["PROPERTY_WIDTH_HEADER_NAME"] = "Width (dimensions)";
$MESS["PROPERTY_HEIGHT_HEADER_NAME"] = "Height (dimensions)";
$MESS["PROPERTY_PICTURE_HEADER_NAME"] = "Photo";
$MESS["PROPERTY_SIZE_HEADER_NAME"] = "Size";
$MESS["SELECT_FIELD_NAME"] = "Field";
$MESS["SELECT_PROPERTY_NAME"] = "Properties";
$MESS["SELECT_WEIGHT_PROPERTY_NAME"] = "Weight (gram)";
$MESS["SELECT_LENGTH_PROPERTY_NAME"] = "Length (mm)";
$MESS["SELECT_WIDTH_PROPERTY_NAME"] = "Width (mm)";
$MESS["SELECT_HEIGHT_PROPERTY_NAME"] = "Height (mm)";
$MESS["UNIT_MEASUREMENT_MM"] = "mm";
$MESS["UNIT_MEASUREMENT_CM"] = "cm";
$MESS["UNIT_MEASUREMENT_M"] = "m";
$MESS["UNIT_MEASUREMENT_MG"] = "mg";
$MESS["UNIT_MEASUREMENT_G"] = "g";
$MESS["UNIT_MEASUREMENT_KG"] = "kg";
$MESS['BASE_PRICE'] = 'Base price';
$MESS['WAIT'] = 'Loading...';
$MESS["OFFERS_VALUE"] = "Maximum number of trade offers for a product";

View File

@ -0,0 +1,53 @@
<?php
$MESS['ERROR_FILENAME_NOT_SET'] = 'Не указан файл данных.';
$MESS['ERROR_PROFIE_NOT_SET'] = 'Не указано имя профиля';
$MESS['EXPORT_CATALOGS'] = 'Выберите каталоги для выгрузки в ICML:';
$MESS['CATALOG'] = 'Каталог';
$MESS['EXPORT2INTAROCML'] = 'Выгрузить в ICML';
$MESS['FILENAME'] = 'Укажите имя файла данных:';
$MESS['LOAD_PURCHASE_PRICE'] = 'Выгружать закупочную цену';
$MESS['PROPERTY'] = 'Свойство, содержащее артикул товара';
$MESS['ALL_CATALOG'] = 'Все каталоги';
$MESS['EXPORT'] = 'Экспортировать';
$MESS['SAVE'] = 'Сохранить';
$MESS['ERROR_IBLOCK_MODULE'] = 'Модуль Инфоблоки не установлен';
$MESS['ERROR_IBLOCK_CATALOG'] = 'Модуль Каталог не установлен';
$MESS['ERROR_IBLOCK_INTAROCRM'] = 'Модуль RetailCRM не установлен';
$MESS['ERROR_ARTICLE_NOT_SET'] = 'Были установлены поля артикулов, но не установлены Информационные блоки';
$MESS['PROFILE_NAME'] = 'Имя профиля';
$MESS['SETTINGS_INFOBLOCK'] = 'Настройки инфоблоков';
$MESS['SETTINGS_EXPORT'] = 'Настройки экспорта';
$MESS['CHECK_ALL_INFOBLOCKS'] = 'Выбрать все инфоблоки ';
$MESS['LOADED_PROPERTY'] = 'Выгружаемое свойство';
$MESS['PROPERTY_PRODUCT_HEADER_NAME'] = 'Свойство товара';
$MESS['PROPERTY_OFFER_HEADER_NAME'] = 'Свойство торгового предложения';
$MESS['PROPERTY_ARTICLE_HEADER_NAME'] = 'Артикул';
$MESS['PROPERTY_MANUFACTURER_HEADER_NAME'] = 'Производитель';
$MESS['PROPERTY_COLOR_HEADER_NAME'] = 'Цвет';
$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'] = 'Свойства';
$MESS['SELECT_WEIGHT_PROPERTY_NAME'] = 'Вec (грамм)';
$MESS['SELECT_LENGTH_PROPERTY_NAME'] = 'Длина (мм.)';
$MESS['SELECT_WIDTH_PROPERTY_NAME'] = 'Ширина (мм.)';
$MESS['SELECT_HEIGHT_PROPERTY_NAME'] = 'Высота (мм.)';
$MESS['UNIT_MEASUREMENT_MM'] = 'мм.';
$MESS['UNIT_MEASUREMENT_CM'] = 'см.';
$MESS['UNIT_MEASUREMENT_M'] = 'м.';
$MESS['UNIT_MEASUREMENT_MG'] = 'мг.';
$MESS['UNIT_MEASUREMENT_G'] = 'г.';
$MESS['UNIT_MEASUREMENT_KG'] = 'кг.';
$MESS['BASE_PRICE'] = 'Базовая цена';
$MESS['WAIT'] = 'Загрузка...';
$MESS['OFFERS_VALUE'] = 'Максимальное количество торговых предложений у товара';
$MESS['ERROR_NO_FILENAME'] = 'Не указано имя файла для экспорта.';
$MESS['FILE_ACCESS_DENIED'] = 'Недостаточно прав для перезаписи файла #FILE#';
$MESS['ERROR_NO_PROFILE_NAME'] = 'Введите название профиля выгрузки.';
$MESS['PROFILE_NAME_EXAMPLE'] = 'Выгрузка каталога RetailCRM';

View File

@ -6,6 +6,7 @@ use Bitrix\Main\ArgumentException;
use Bitrix\Main\ObjectPropertyException; use Bitrix\Main\ObjectPropertyException;
use Bitrix\Main\SystemException; use Bitrix\Main\SystemException;
use Intaro\RetailCrm\Service\Hl; use Intaro\RetailCrm\Service\Hl;
use Logger;
/** /**
* Class HlRepository * Class HlRepository
@ -41,7 +42,8 @@ class HlRepository
return $result; return $result;
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) { } catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
AddMessage2Log($exception->getMessage()); Logger::getInstance()->write($exception->getMessage(), 'repositoryErrors');
return null; return null;
} }
} }

View File

@ -3,6 +3,7 @@
namespace Intaro\RetailCrm\Service; namespace Intaro\RetailCrm\Service;
use Bitrix\Main\ArgumentException; use Bitrix\Main\ArgumentException;
use Bitrix\Main\Entity\Base;
use Bitrix\Main\Entity\DataManager; use Bitrix\Main\Entity\DataManager;
use Bitrix\Main\Loader; use Bitrix\Main\Loader;
use Bitrix\Highloadblock as Highloadblock; use Bitrix\Highloadblock as Highloadblock;
@ -22,14 +23,32 @@ class Hl
/** /**
* Получение DataManager класса управления HLBlock * Получение DataManager класса управления HLBlock
* *
* @param int $HlBlockId * @param int $hlBlockId
*
* @return \Bitrix\Main\Entity\DataManager|null * @return \Bitrix\Main\Entity\DataManager|null
* @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ArgumentException
* @throws \Bitrix\Main\LoaderException * @throws \Bitrix\Main\LoaderException
* @throws \Bitrix\Main\ObjectPropertyException * @throws \Bitrix\Main\ObjectPropertyException
* @throws \Bitrix\Main\SystemException * @throws \Bitrix\Main\SystemException
*/ */
public static function getHlClassById(int $HlBlockId): ?DataManager public static function getHlClassById(int $hlBlockId): ?DataManager
{
$entity = self::getBaseEntityByHlId($hlBlockId);
return $entity->getDataClass();
}
/**
* @param int $HlBlockId
*
* @return \Bitrix\Main\Entity\Base|null
* @throws \Bitrix\Main\ArgumentException
* @throws \Bitrix\Main\LoaderException
* @throws \Bitrix\Main\ObjectPropertyException
* @throws \Bitrix\Main\SystemException
*/
public static function getBaseEntityByHlId(int $HlBlockId): ?Base
{ {
Loader::includeModule('highloadblock'); Loader::includeModule('highloadblock');
@ -39,25 +58,26 @@ class Hl
return null; return null;
} }
$entity = Highloadblock\HighloadBlockTable::compileEntity($hlblock); return Highloadblock\HighloadBlockTable::compileEntity($hlblock);
return $entity->getDataClass();
} }
/** /**
* Получение DataManager класса управления HLBlock по названию таблицы * @param string|null $tableName
* *
* @param string $name * @return \Bitrix\Main\Entity\Base|null
* @return \Bitrix\Main\Entity\DataManager|string|null
*/ */
public static function getHlClassByTableName(string $name) public static function getBaseEntityByTableName(?string $tableName): ?Base
{ {
if (!$tableName) {
return null;
}
try { try {
Loader::includeModule('highloadblock'); Loader::includeModule('highloadblock');
$hlblock = Highloadblock\HighloadBlockTable::query() $hlblock = Highloadblock\HighloadBlockTable::query()
->addSelect('*') ->addSelect('*')
->where('TABLE_NAME', '=', $name) ->where('TABLE_NAME', '=', $tableName)
->exec() ->exec()
->fetch(); ->fetch();
@ -65,12 +85,28 @@ class Hl
return null; return null;
} }
$entity = Highloadblock\HighloadBlockTable::compileEntity($hlblock); return Highloadblock\HighloadBlockTable::compileEntity($hlblock);
return $entity->getDataClass();
} catch (ObjectPropertyException | ArgumentException | SystemException | LoaderException $exception) { } catch (ObjectPropertyException | ArgumentException | SystemException | LoaderException $exception) {
AddMessage2Log($exception->getMessage()); AddMessage2Log($exception->getMessage());
return null; return null;
} }
} }
/**
* Получение DataManager класса управления HLBlock по названию таблицы
*
* @param string $name
* @return \Bitrix\Main\Entity\DataManager|null|string
*/
public static function getHlClassByTableName(string $name)
{
$entity = self::getBaseEntityByTableName($name);
if ($entity instanceof Base) {
return $entity->getDataClass();
}
return null;
}
} }

View File

@ -1,29 +1,149 @@
<?php <?php
$rcrmVersionFile = __DIR__ . '/install/version.php'; use Bitrix\Main;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\ORM\Objectify\EntityObject;
if(!CModule::IncludeModule('intaro.retailcrm') try {
|| !CModule::IncludeModule('sale') update();
|| !CModule::IncludeModule('iblock') } catch (Main\ObjectPropertyException | Main\ArgumentException | Main\SystemException $exception) {
|| !CModule::IncludeModule('catalog')
|| !file_exists($rcrmVersionFile)
) {
return; return;
} }
include_once $rcrmVersionFile; /**
* @throws \Bitrix\Main\ArgumentException
* @throws \Bitrix\Main\ObjectPropertyException
* @throws \Bitrix\Main\SystemException
*/
function update()
{
/** @var EntityObject $exportSystem */
$exportSystem = UpdaterRetailExportTable::query()
->addSelect('*')
->where('FILE_NAME', 'retailcrm')
->fetchObject();
if (!isset($arModuleVersion['VERSION'])) { replaceExportVars($exportSystem);
return;
} }
$rcrmCurrentUpdateFile = __DIR__ . '/update/' . sprintf('updater-%s.php', $arModuleVersion['VERSION']); /**
* @throws \Bitrix\Main\SystemException
* @throws \Bitrix\Main\ArgumentException
*/
function replaceExportVars(EntityObject $exportSystem)
{
$replaceableVars = [
['search' => 'IBLOCK_EXPORT', 'replace' => 'iblockExport'],
['search' => 'IBLOCK_PROPERTY_SKU', 'replace' => 'iblockPropertySku'],
['search' => 'IBLOCK_PROPERTY_UNIT_SKU', 'replace' => 'iblockPropertyUnitSku'],
['search' => 'IBLOCK_PROPERTY_PRODUCT', 'replace' => 'iblockPropertyProduct'],
['search' => 'IBLOCK_PROPERTY_UNIT_PRODUCT', 'replace' => 'iblockPropertyUnitProduct'],
['search' => 'MAX_OFFERS_VALUE', 'replace' => 'maxOffersValue'],
];
$setupVars = $exportSystem->get('SETUP_VARS');
$newSetupVars = str_replace(
array_column($replaceableVars,'search'),
array_column($replaceableVars, 'replace'),
$setupVars
);
if (file_exists($rcrmCurrentUpdateFile)) { $exportSystem->set('SETUP_VARS', $newSetupVars);
include_once $rcrmCurrentUpdateFile; $exportSystem->save();
$functionName = 'update_' . str_replace('.', '_', $arModuleVersion['VERSION']); }
if (function_exists($functionName)) {
$functionName(); class UpdaterRetailExportTable extends Main\Entity\DataManager
{
/**
* Returns DB table name for entity.
*
* @return string
*/
public static function getTableName(): string
{
return 'b_catalog_export';
}
/**
* Returns entity map definition.
*
* @return array
*/
public static function getMap(): array
{
return [
'ID' => [
'data_type' => 'integer',
'primary' => true,
'autocomplete' => true,
'title' => Loc::getMessage('EXPORT_ENTITY_ID_FIELD'),
],
'FILE_NAME' => [
'data_type' => 'string',
'required' => true,
'validation' => [__CLASS__, 'validateFileName'],
'title' => Loc::getMessage('EXPORT_ENTITY_FILE_NAME_FIELD'),
],
'NAME' => [
'data_type' => 'string',
'required' => true,
'validation' => [__CLASS__, 'validateName'],
'title' => Loc::getMessage('EXPORT_ENTITY_NAME_FIELD'),
],
'DEFAULT_PROFILE' => [
'data_type' => 'boolean',
'values' => ['N', 'Y'],
'title' => Loc::getMessage('EXPORT_ENTITY_DEFAULT_PROFILE_FIELD'),
],
'IN_MENU' => [
'data_type' => 'boolean',
'values' => ['N', 'Y'],
'title' => Loc::getMessage('EXPORT_ENTITY_IN_MENU_FIELD'),
],
'IN_AGENT' => [
'data_type' => 'boolean',
'values' => ['N', 'Y'],
'title' => Loc::getMessage('EXPORT_ENTITY_IN_AGENT_FIELD'),
],
'IN_CRON' => [
'data_type' => 'boolean',
'values' => ['N', 'Y'],
'title' => Loc::getMessage('EXPORT_ENTITY_IN_CRON_FIELD'),
],
'SETUP_VARS' => [
'data_type' => 'text',
'title' => Loc::getMessage('EXPORT_ENTITY_SETUP_VARS_FIELD'),
],
'LAST_USE' => [
'data_type' => 'datetime',
'title' => Loc::getMessage('EXPORT_ENTITY_LAST_USE_FIELD'),
],
'IS_EXPORT' => [
'data_type' => 'boolean',
'values' => ['N', 'Y'],
'title' => Loc::getMessage('EXPORT_ENTITY_IS_EXPORT_FIELD'),
],
'NEED_EDIT' => [
'data_type' => 'boolean',
'values' => ['N', 'Y'],
'title' => Loc::getMessage('EXPORT_ENTITY_NEED_EDIT_FIELD'),
],
'TIMESTAMP_X' => [
'data_type' => 'datetime',
'title' => Loc::getMessage('EXPORT_ENTITY_TIMESTAMP_X_FIELD'),
],
'MODIFIED_BY' => [
'data_type' => 'integer',
'title' => Loc::getMessage('EXPORT_ENTITY_MODIFIED_BY_FIELD'),
],
'DATE_CREATE' => [
'data_type' => 'datetime',
'title' => Loc::getMessage('EXPORT_ENTITY_DATE_CREATE_FIELD'),
],
'CREATED_BY' => [
'data_type' => 'integer',
'title' => Loc::getMessage('EXPORT_ENTITY_CREATED_BY_FIELD'),
],
];
} }
} }