M
M
m4son2022-03-09 14:05:12
1C-Bitrix
m4son, 2022-03-09 14:05:12

How to track a change in a product property in 1C-Bitrix?

The product has a property (checkbox), and it is not clear how it works. I remove the checkbox, save it, but it does not go away.
There is nothing in the init.php file.
How can you track. what event and function change it before saving?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
m4son, 2022-03-09
@m4son

Found. In the init.php file, you need to add the following function to the "OnIBlockElementSetPropertyValuesEx" event:

\Bitrix\Main\EventManager::getInstance()->addEventHandler('iblock', 'OnIBlockElementSetPropertyValuesEx',"OnIBlockElementSetPropertyValuesExHandler");

function OnIBlockElementSetPropertyValuesExHandler($ELEMENT_ID, $IBLOCK_ID, $PROPERTY_VALUES, $propertyList, $arDBProps) {
  define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"] . "/log-prop.txt");
    AddMessage2Log(print_r($PROPERTY_VALUES, 1));
}

After that, the property code, value, and below the links to the files and lines that were involved will appear in the logs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question