Bitrix: exchange with 1C
Rus
Eng
Битрикс: обмен с 1С

All English-language materials have been translated fully automatically using the Google service

Settings for connecting to 1C must be made according to official documentation

Error[[1813] Tablespace '`sitemanager `.`b_xml_tree_import_1c`' exists.]

b_xml_tree_import_1c is a temporary table dynamically created during import. Import means any XML import, and not just downloading from 1C

In very rare cases, a table becomes so damaged that it becomes impossible to create or delete it. This is evidenced by the number errno: 184. This case is easy to diagnose. Make sure that the table b_xml_tree_import_1c is not in the database and try executing the code:

create table b_xml_tree_import_1c
(
	ID int(11) not null auto_increment,

	PARENT_ID int(11),
	LEFT_MARGIN int(11),
	RIGHT_MARGIN int(11),
	DEPTH_LEVEL int(11),
	NAME varchar(255),
	VALUE longtext,
	ATTRIBUTES text,
	PRIMARY KEY (ID)
)

If you get an error, then go to the mysql repository on the server. Find table b_xml_tree_import_1c.frm and delete it.

We correct the overwriting of the product description when exchanging with 1C

$eventManager->addEventHandler("iblock", "OnBeforeIBlockElementUpdate", ['Stsol\Exchange\1C', 'OnBeforeIBlockElementUpdateHandler']);

public static function OnBeforeIBlockElementUpdateHandler(&$arFields)
{
    if (@$_REQUEST['mode']=='import')
    {
        unset($arFields['DETAIL_TEXT']); // Не перезаписывать детальное описание элементов из 1С
    }

Clearing the cache after import

In the init.php file, add

// When importing from 1C starts, set the session variable
AddEventHandler(
    'catalog',
    'OnBeforeCatalogImport1C',
    function ()
    {
        $_SESSION["1C_UPDATE"] = true;
    }
);

// At the end of import from 1C, set the session variable
AddEventHandler(
    'catalog',
    'OnSuccessCatalogImport1C',
    function ()
    {
        $_SESSION["1C_UPDATE"] = false;

        define('BX_BUFFER_USED', true);
        define('NO_KEEP_STATISTIC', true);
        define('NOT_CHECK_PERMISSIONS', true);
        define('NO_AGENT_STATISTIC', true);
        define('STOP_STATISTICS', true);
        define('SITE_ID', 's1');

        BXClearCache(true);

        if (class_exists('\Bitrix\Main\Data\ManagedCache')) {
            (new \Bitrix\Main\Data\ManagedCache())->cleanAll();
        }

        if (class_exists('\CStackCacheManager')) {
            (new \CStackCacheManager())->CleanAll();
        }

        if (class_exists('\Bitrix\Main\Data\StaticHtmlCache')) {
            \Bitrix\Main\Data\StaticHtmlCache::getInstance()->deleteAll();
        }
    }
);

Starting import manually

To do this, go to the address: https://site.ru/bitrix/admin/1c_exchange.php?type=catalog&mode=import&filename=import.xml

The import can also be started from the debug file /bx_1c_import.php , which is much more convenient, but unsafe! Rename it and delete it immediately after use

Enable debugging

In the file /bitrix/php_interface/dbconn.php add a constant

define("BX_CATALOG_IMPORT_1C_PRESERVE", true);

For each updated file, we get an array like

Host: site.ru:443
Date: 2020-06-29 09:23:48
Module: ------------UPDATE-----------
Array
(
    [ACTIVE] => Y
    [PROPERTY_VALUES] => Array
        (
                )

            [339] => Array
                (
                    [n0] => Array
                        (
                            [VALUE] => 5055185210794
                            [DESCRIPTION] => 
                        )

                )

            [340] => Array
                (
                    [n0] => Array
                        (
                            [VALUE] => 5678000-01109
                            [DESCRIPTION] => 
                        )

                )

            [342] => Array
                (
                    [n0] => Array
                        (
                            [VALUE] => Товар 
                            [DESCRIPTION] => ВидНоменклатуры
                        )

                    [n1] => Array
                        (
                            [VALUE] => Товар
                            [DESCRIPTION] => ТипНоменклатуры
                        )

                    [n2] => Array
                        (
                            [VALUE] => Набор для вышивания "Поле маков". По картине Стива Томса ("Poppy Field", Steve Thoms). 25х25 см
                            [DESCRIPTION] => Полное наименование
                        )

                    [n3] => Array
                        (
                            [VALUE] => 1933.83
                            [DESCRIPTION] => Цена
                        )

                    [n4] => Array
                        (
                            [VALUE] => 0
                            [DESCRIPTION] => Вес
                        )

                )

        )

    [TMP_ID] => 1765642395
    [XML_ID] => 583b6b8d-d8f1-11e0-9980-1c6f65bc8a97
    [NAME] => Набор для вышивания MAIA Поле маков
    [DETAIL_TEXT] => Размер:25*25см (состав: канва Aida 16, цветная схема, нитки Anchor, игла, инструкция), счетный крест
    [DETAIL_TEXT_TYPE] => text
    [PREVIEW_TEXT] => Набор для вышивания "Поле маков". По картине Стива Томса ("Poppy Field", Steve Thoms). 25х25 см
    [PREVIEW_TEXT_TYPE] => text
    [DETAIL_PICTURE] => Array
        (
            [name] => 583b6b8d-d8f1-11e0-9980-1c6f65bc8a97_2b668b28-d6b7-11e5-afc8-001e676a37f6.jpg
            [size] => 84906
            [tmp_name] => /home/bitrix/www/upload/1c_catalog/import_files/58/583b6b8d-d8f1-11e0-9980-1c6f65bc8a97_2b668b28-d6b7-11e5-afc8-001e676a37f6.jpg
            [type] => image/jpeg
            [external_id] => 825a18b4d6a465891654f1227d1968e4
            [description] => 09
            [MODULE_ID] => iblock
            [old_file] => 122987
        )

    [PREVIEW_PICTURE] => Array
        (
            [name] => 583b6b8d-d8f1-11e0-9980-1c6f65bc8a97_2b668b28-d6b7-11e5-afc8-001e676a37f6.resize1.jpg
            [size] => 40462
            [tmp_name] => /home/bitrix/www/upload/1c_catalog/import_files/58/583b6b8d-d8f1-11e0-9980-1c6f65bc8a97_2b668b28-d6b7-11e5-afc8-001e676a37f6.resize1.jpg
            [type] => image/jpeg
            [external_id] => 825a18b4d6a465891654f1227d1968e4
            [description] => 09
            [MODULE_ID] => iblock
            [old_file] => 122986
        )

    [IBLOCK_SECTION] => Array
        (
            [0] => 1217
        )

    [BASE_WEIGHT] => 0
    [MODIFIED_BY] => 1
    [WF] => N
    [SEARCHABLE_CONTENT] => НАБОР ДЛЯ ВЫШИВАНИЯ MAIA ПОЛЕ МАКОВ
НАБОР ДЛЯ ВЫШИВАНИЯ "ПОЛЕ МАКОВ". ПО КАРТИНЕ СТИВА ТОМСА ("POPPY FIELD", STEVE THOMS). 25Х25 СМ
РАЗМЕР:25*25СМ (СОСТАВ: КАНВА AIDA 16, ЦВЕТНАЯ СХЕМА, НИТКИ ANCHOR, ИГЛА, ИНСТРУКЦИЯ), СЧЕТНЫЙ КРЕСТ
    [PREVIEW_PICTURE_ID] => 136021
    [DETAIL_PICTURE_ID] => 136022
    [ID] => 116896
    [IBLOCK_ID] => 22
    [RESULT] => 1
)

Search for a problem file when receiving during import from 1C response The file is not graphic

In the file /bitrix/modules/main/classes/general/file.php before each

return GetMessage("FILE_BAD_FILE_TYPE");

insert:

print_r($arFile)

Get an array like

[
	[name] => 493d6d81-6ebb-11e3-8f8e-001e676a37f6_493d6d83-6ebb-11e3-8f8e-001e676a37f6.jpg
	[size] => 1051
	[tmp_name] => /home/bitrix/www/upload/1c_catalog/import_files/49/493d6d81-6ebb-11e3-8f8e-001e676a37f6_493d6d83-6ebb-11e3-8f8e-001e676a37f6.jpg
	[type] => image/jpeg
	[external_id] => b6c6e1bf0372a666323fd0a000999734
	[description] => PN-0146947
	[MODULE_ID] => iblock
	[old_file] => 
]

Now in the import.xml file we can find the id of the problem product by the image name

If you do not want errors to be repeated and you are not critical of their absence when working with the admin panel, then you can skip processing them, which will allow the import script to continue further if they occur.

Instead of print_r add the following code to /bitrix/modules/main/classes/general/file.php file

$log = '///////////////////////////////////////////////////////////////n';
$log .= date('Y-m-d H:i:s') . ' ' . print_r($arFile, true);
//$log .= str_replace(array('	', PHP_EOL), '', print_r($arFile, true)); //For one line output
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/log.txt', $log . PHP_EOL, FILE_APPEND);

Uploading to the site was completed with errors. import.xml: A server side error has occurred. Unknown import status received.

1С returned response code Error opening file

If you make sure that there is enough space on your hard disk, your script has access rights to the /upload/ folder and the folder itself exists, then try disabling compression when exchanging with 1C.

Follow the link /bitrix/admin/1c_admin.php?lang=ru&tabControl_active_tab=edit_catalog or use Shop > Settings > Integration with 1C and uncheck the option < code>Use zip compression when available

Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number