Answer the question
In order to leave comments, you need to log in
How to change the number of goods after the exchange of 1s Bitrix?
After the exchange, I need to change the available quantity of goods, I do this
AddEventHandler('catalog', 'OnCompleteCatalogImport1C', 'quantityCatalogImportStep');
function quantityCatalogImportStep()
{
$addProps = CIBlockElement::GetList (
Array("QUANTITY" => "ASC"),
Array("IBLOCK_ID" => 18),
false,
false,
Array(
'ID', 'QUANTITY', 'NAME', 'PROPERTY_MIN_UPAKOVKA'
)
);
while($ar_fields = $addProps->GetNext())
{
$kolvo = $ar_fields['QUANTITY'];
$min_upakovka = $ar_fields['PROPERTY_MIN_UPAKOVKA_VALUE'];
$new_kolvo = (int)($kolvo / $min_upakovka);
if ($ar_fields['QUANTITY'] > 0 && $ar_fields['PROPERTY_MIN_UPAKOVKA_VALUE'] > 0) {
Cmodule::IncludeModule('catalog');
$PRODUCT_ID = $ar_fields['ID'];
$arFields = array(
'QUANTITY' => $new_kolvo
);
CCatalogProduct::Update($PRODUCT_ID, $arFields);
}
}
}
Answer the question
In order to leave comments, you need to log in
Have you tried changing the quantity during the exchange?
An example handler can be viewed here .
And a couple of notes:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question