Answer the question
In order to leave comments, you need to log in
Why doesn't CCatalogProduct::Update work when adding a new item?
Good afternoon!
There is a task: when adding a new product to Bitrix, automatically put down its quantity.
My code:
AddEventHandler("iblock", "OnAfterIBlockElementAdd", Array("UpdateClass", "OnAfterIBlockElementAddHandler"));
class UpdateClass
{
function OnAfterIBlockElementAddHandler(&$arFields)
{
$PRODUCT_ID = $arFields['ID'];
$arFields = array('ID' => $arFields['ID'], 'QUANTITY' => 1);// количество товара
CCatalogProduct::Update($PRODUCT_ID, $arFields);
}
}
Answer the question
In order to leave comments, you need to log in
You confuse adding a new product and a new infoblock element. These are two different tables and different modules.
For the "when adding a product" event, you need an OnProductAdd
handler
And here see other possible events of the "shopping catalog" module
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question