Answer the question
In order to leave comments, you need to log in
Which event is better to use to change quantity after import?
I hung up the change in the number of goods on the OnSuccessCatalogImport1C event, but as I understand it, it works after 1 package of changes (3k products, and 300 packages each), it turns out that after 10 xml packages, I have an inadequate number of products. How can this be fixed?
AddEventHandler('catalog', 'OnSuccessCatalogImport1C', '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) {
echo 'Товару с ID-' . $ar_fields['ID'] .' установлены параметры';
echo 'Новое количество:' . $new_kolvo.'
';
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question