Answer the question
In order to leave comments, you need to log in
How to set the quantity of goods automatically in Bitrix when adding?
Good afternoon!
Website edited by Small Business. There is a task - when adding a product to the Bitrix catalog, you need to automatically register the article, and the quantity of the product should automatically be scored equal to 1. I figured out the article, the code is given below.
AddEventHandler("iblock", "OnBeforeIBlockElementAdd", Array("ArtClass", "OnBeforeIBlockElementAddHandler"));
class ArtClass
{
function OnBeforeIBlockElementAddHandler(&$arFields)
{
$arSort= Array();
$arFilter = Array("IBLOCK_ID"=>4, "ID"=>$arFields['ID']);
$arSelect = Array();
$res = CIBlockElement::GetList($arSort, $arFilter, false, false, $arSelect);
$res2 = $res->Fetch();
if($arFields['IBLOCK_ID'] == 4)
{
$arFields['PROPERTY_VALUES'][306] = $res2["ID"];
}
}
}
Answer the question
In order to leave comments, you need to log in
CCatalogProduct
::Update
https://dev.1c-bitrix.ru/api_help/catalog/classes/...
after the element itself has been created.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question