I
I
Ilya17912017-01-16 13:50:09
CMS
Ilya1791, 2017-01-16 13:50:09

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"];
        }      
    }
}

And with the amount of goods there was a plug. How to do the same for the quantity on the Internet did not find suitable information. Please tell me how can this be done.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Korolev, 2017-01-16
@workDNK

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 question

Ask a Question

731 491 924 answers to any question