1
0
mirror of synced 2024-11-30 01:06:06 +03:00
bitrix-module/intaro.retailcrm/updater.php

150 lines
5.0 KiB
PHP
Raw Normal View History

<?php
2021-09-08 10:05:09 +03:00
use Bitrix\Main;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\ORM\Objectify\EntityObject;
2021-09-08 10:05:09 +03:00
try {
update();
} catch (Main\ObjectPropertyException | Main\ArgumentException | Main\SystemException $exception) {
return;
}
2021-09-08 10:05:09 +03:00
/**
* @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();
replaceExportVars($exportSystem);
}
2021-09-08 10:05:09 +03:00
/**
* @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
);
$exportSystem->set('SETUP_VARS', $newSetupVars);
$exportSystem->save();
}
2021-09-08 10:05:09 +03:00
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'),
],
];
}
}