1
0
mirror of synced 2024-11-28 00:06:07 +03:00
bitrix-module/intaro.retailcrm/export/export_run.php

134 lines
4.5 KiB
PHP
Raw Normal View History

2013-09-12 17:31:32 +04:00
<?php
2015-05-18 17:38:06 +03:00
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");
2016-10-04 17:57:39 +03:00
} else {
2015-05-18 17:38:06 +03:00
ignore_user_abort(true);
set_time_limit(0);
2013-09-12 17:31:32 +04:00
2015-05-18 17:38:06 +03:00
global $APPLICATION;
2016-10-04 17:57:39 +03:00
if (!CModule::IncludeModule("iblock")){
2015-05-18 17:38:06 +03:00
return;
2016-10-04 17:57:39 +03:00
}
if (!CModule::IncludeModule("catalog")){
2015-05-18 17:38:06 +03:00
return;
2016-10-04 17:57:39 +03:00
}
if (!CModule::IncludeModule("intaro.retailcrm")){
2015-05-18 17:38:06 +03:00
return;
2016-10-04 17:57:39 +03:00
}
2015-05-18 17:38:06 +03:00
$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
2016-10-04 17:57:39 +03:00
while ($ar = $rsSites->Fetch()) {
if ($ar['DEF'] == 'Y') {
2016-09-15 16:42:10 +03:00
$SERVER_NAME = $ar['SERVER_NAME'];
2015-05-18 17:38:06 +03:00
}
2015-03-03 16:37:34 +03:00
}
2018-05-23 12:19:59 +03:00
$hlblockModule = false;
2018-03-22 16:11:04 +03:00
2018-05-23 12:19:59 +03:00
if (CModule::IncludeModule('highloadblock')) {
$hlblockModule = true;
$hlblockList = array();
$hlblockListDb = \Bitrix\Highloadblock\HighloadBlockTable::getList();
while ($hlblockArr = $hlblockListDb->Fetch()) {
$hlblockList[$hlblockArr["TABLE_NAME"]] = $hlblockArr;
}
2018-03-22 16:11:04 +03:00
}
2016-10-04 17:57:39 +03:00
$iblockProperties = array(
"article" => "article",
"manufacturer" => "manufacturer",
"color" =>"color",
"weight" => "weight",
"size" => "size",
"length" => "length",
"width" => "width",
"height" => "height",
);
2015-05-18 17:38:06 +03:00
$IBLOCK_PROPERTY_SKU = array();
2018-03-22 16:11:04 +03:00
$IBLOCK_PROPERTY_SKU_HIGHLOADBLOCK = array();
2015-05-18 17:38:06 +03:00
$IBLOCK_PROPERTY_UNIT_SKU = array();
foreach ($iblockProperties as $prop) {
$skuUnitProps = ('IBLOCK_PROPERTY_UNIT_SKU' . "_" . $prop);
$skuUnitProps = $$skuUnitProps;
if (is_array($skuUnitProps)) {
foreach ($skuUnitProps as $iblock => $val) {
$IBLOCK_PROPERTY_UNIT_SKU[$iblock][$prop] = $val;
}
}
2014-04-15 20:31:11 +04:00
2015-05-18 17:38:06 +03:00
$skuProps = ('IBLOCK_PROPERTY_SKU' . "_" . $prop);
$skuProps = $$skuProps;
if (is_array($skuProps)) {
foreach ($skuProps as $iblock => $val) {
$IBLOCK_PROPERTY_SKU[$iblock][$prop] = $val;
}
}
2018-03-22 16:11:04 +03:00
2018-05-23 12:19:59 +03:00
if ($hlblockModule === true) {
foreach ($hlblockList as $hlblockTable => $hlblock) {
$hbProps = ('highloadblock' . $hlblockTable . '_' . $prop);
$hbProps = $$hbProps;
2018-03-22 16:11:04 +03:00
2018-05-23 12:19:59 +03:00
if (is_array($hbProps)) {
foreach ($hbProps as $iblock => $val) {
$IBLOCK_PROPERTY_SKU_HIGHLOADBLOCK[$hlblockTable][$iblock][$prop] = $val;
}
2018-03-22 16:11:04 +03:00
}
}
}
2013-10-02 17:42:20 +04:00
}
2018-05-23 12:19:59 +03:00
2015-05-18 17:38:06 +03:00
$IBLOCK_PROPERTY_PRODUCT = array();
2018-03-22 16:11:04 +03:00
$IBLOCK_PROPERTY_PRODUCT_HIGHLOADBLOCK = array();
2015-05-18 17:38:06 +03:00
$IBLOCK_PROPERTY_UNIT_PRODUCT = array();
foreach ($iblockProperties as $prop) {
$productUnitProps = "IBLOCK_PROPERTY_UNIT_PRODUCT" . "_" . $prop;
$productUnitProps = $$productUnitProps;
if (is_array($productUnitProps)) {
foreach ($productUnitProps as $iblock => $val) {
$IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock][$prop] = $val;
}
}
2014-04-15 20:31:11 +04:00
2015-05-18 17:38:06 +03:00
$productProps = "IBLOCK_PROPERTY_PRODUCT" . "_" . $prop;
$productProps = $$productProps;
if (is_array($productProps)) {
foreach ($productProps as $iblock => $val) {
$IBLOCK_PROPERTY_PRODUCT[$iblock][$prop] = $val;
}
}
2018-03-22 16:11:04 +03:00
2018-05-23 12:19:59 +03:00
if ($hlblockModule === true) {
foreach ($hlblockList as $hlblockTable => $hlblock) {
$hbProps = ('highloadblock_product' . $hlblockTable . '_' . $prop);
$hbProps = $$hbProps;
2018-03-22 16:11:04 +03:00
2018-05-23 12:19:59 +03:00
if (is_array($hbProps)) {
foreach ($hbProps as $iblock => $val) {
$IBLOCK_PROPERTY_PRODUCT_HIGHLOADBLOCK[$hlblockTable][$iblock][$prop] = $val;
}
2018-03-22 16:11:04 +03:00
}
}
}
2013-10-02 17:42:20 +04:00
}
2016-09-15 16:42:10 +03:00
$loader = new RetailCrmICML();
2015-05-18 17:38:06 +03:00
$loader->profileID = $PROFILE_ID;
$loader->iblocks = $IBLOCK_EXPORT;
$loader->propertiesSKU = $IBLOCK_PROPERTY_SKU;
$loader->propertiesUnitSKU = $IBLOCK_PROPERTY_UNIT_SKU;
$loader->propertiesProduct = $IBLOCK_PROPERTY_PRODUCT;
$loader->propertiesUnitProduct = $IBLOCK_PROPERTY_UNIT_PRODUCT;
2018-05-23 12:19:59 +03:00
if ($hlblockModule === true) {
$loader->highloadblockSkuProperties = $IBLOCK_PROPERTY_SKU_HIGHLOADBLOCK;
$loader->highloadblockProductProperties = $IBLOCK_PROPERTY_PRODUCT_HIGHLOADBLOCK;
}
2015-05-18 17:38:06 +03:00
$loader->filename = $SETUP_FILE_NAME;
$loader->serverName = $SERVER_NAME;
$loader->application = $APPLICATION;
$loader->loadPurchasePrice = $LOAD_PURCHASE_PRICE == 'Y';
$loader->Load();
}