A
A
Alexander2022-03-05 12:11:49
1C-Bitrix
Alexander, 2022-03-05 12:11:49

How to get the product ID after updating from 1C?

After the exchange of balances and prices, you need to transfer them to the markets. How to get data (product ID) immediately after updating from 1C?
Here I throw in order to display in the log what happens after the exchange

AddEventHandler('catalog', 'OnSuccessCatalogImport1C', 'OnBeforeAllPriceUpdateHandler');
function OnBeforeAllPriceUpdateHandler(&$arFields)
{
    Cmodule::IncludeModule("catalog");
    Cmodule::IncludeModule("iblock");
    Cmodule::IncludeModule("sale");

    AddMessage2Log("1с обновлен: arFields", print_r($arFields));
}


get

----------
Host: хххххххххх
Date: 2022-03-05 13:39:00
Module: 1
1C обновлен: arFields 
    OnBeforeAllPriceUpdateHandler < ExecuteModuleEventEx < include < CBitrixComponent::__includeComponent < CBitrixComponent::executeComponent
  /www/bitrix/modules/main/classes/general/module.php:475
  /www/local/components/realweb/catalog.import.1c/component.php:474
  /www/bitrix/modules/main/classes/general/component.php:594
  /www/bitrix/modules/main/classes/general/component.php:102
  www/bitrix/modules/main/classes/general/component.php:638
----------

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Morozov, 2022-03-10
@Q_BASIC

In $arFields you will not get anything you need in your case. See the documentation for the OnSuccessCatalogImport1C event.
What can be done in your case:
1. Add a handler to the OnSuccessCatalogImport1C event
Further in the handler:
1. Get the time of the last data transfer to the market from some temporary file (in UNIX TIME format). If there is no file, then it has not been transferred yet.
2. Store the current time in a variable.
3. We get the goods by the TIMESTAMP_X filter of the goods more than time from the file. So we will get the products that have been updated since the last data transfer to the market.
4. We send goods to the market.
5 Save the time from our variable to the file (integration start time). If we take the current time at this step, then the products updated during the execution of paragraphs 4 and 5 will not fall into either the current unloading or the next one.
So after integration with 1C, all updated products will go to another system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question