Answer the question
In order to leave comments, you need to log in
How to copy items when exchanging to another section?
The bottom line is that if you make a page with the products of the section according to some attribute, then the "smart" filter shows the values for all the products in the section. for some filter values there will be 0 products.
Therefore, I want to duplicate products in another section and display its products. But the goods are essentially the same.
I need to copy them during the exchange, to a new section (and there will be several of them), and not create duplicates.
I suppose you need to hang a handler on the OnBeforeIBlockElementAdd and OnBeforeIBlockElementUpdate events .
And then how to catch the goods, get their property and copy the goods with a certain value of the property to another section?
Answer the question
In order to leave comments, you need to log in
In general terms, the checklist is as follows:
In the OnBeforeIBlockElementAdd event , the $arFields array will contain the necessary data to create a duplicate product using the API. An example of an array https://yadi.sk/d/V19S_ncKNVif4g
In the event handler:
function OnAfterIBlockElementAddHandler(&$arFields)
{
if($arFields["ID"]>0) {
If($arFields['IBLOCK_ID'] == 5) {//инфоблок каталога
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question