M
M
mirexdoors2018-08-17 18:52:11
1C-Bitrix
mirexdoors, 2018-08-17 18:52:11

Why doesn't the product add event fire?

Good day!
It is necessary to make the following functionality: when adding a product to the sales catalog: create a TP for it. I hang the handler:

AddEventHandler("sale", "OnProductAdd", "OnProductAddHandler");

I add a product, but the event does not fire. Where am I wrong?
PS: I also tried
AddEventHandler("catalog", "OnBeforeProductAdd", "OnProductAddHandler");

also no result

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-08-17
Madzhugin @Suntechnic

These events are triggered specifically for adding a PRODUCT to the catalog (ie, for CCatalogProduct::Add ), and you are probably expecting an item to be triggered - that's not how it works. The IB element is not a catalog item. A catalog product is, simply speaking, information about the price of an IB element (there are actually still taxes, units of measurement, etc.) and the event will work when you set a price on the element, because it is at this moment that the catalog product is created.
And you apparently do not add a price, because you want to create a TP.
But this is good - imagine what would happen if it worked? You want to generate a TP for each addition of a product, i.e.... ADD A PRODUCT.
Do you understand what will happen?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question