Answer the question
In order to leave comments, you need to log in
How to rewrite the function of updating the field Coefficient of the unit of measure to the new syntax?
AddEventHandler("catalog", "OnPriceUpdate", "HandlerOnPriceUpdate");
function HandlerOnPriceUpdate($ID,&$arFields)
{
$element = $arFields['PRODUCT_ID']; //ID товара
$iblockId = 9;
/*$coeff= CIBlockElement::GetByID($arFields['PRODUCT_ID'])->GetNextElement()->GetProperties('VES_V_GRAMMAKH_SHAG');*/ //например
$coeff= 100;
$curElementRatio = CCatalogMeasureRatio::getList(
Array(),
array('IBLOCK_ID' => $iblockId, 'PRODUCT_ID' => $element ),
false, false);
while ($arRatio = $curElementRatio->GetNext()) {
$ratioId = $arRatio['ID'];
$arFieldsNew = Array(
'RATIO' => $coeff,
);
CCatalogMeasureRatio::update($ratioId, $arFieldsNew);
}
}
$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler(
'catalog',
'\Bitrix\Catalog\Price::OnAfterUpdate',
static function ( $event ) {
$result = new \Bitrix\Main\ORM\EventResult;
$arFields = $event->getParameter('fields');
$iblockId = 9;
/*** получаем ID товара*/
$element = $event->getParameter('primary')['ID'];
$coeff= CIBlockElement::GetByID($arFields['PRODUCT_ID'])->GetNextElement()->GetProperties('VES_V_GRAMMAKH_SHAG'); //например
$curElementRatio = CCatalogMeasureRatio::getList(
Array(),
array('IBLOCK_ID' => $iblockId, 'PRODUCT_ID' => $element ),
false, false);
while ($arRatio = $curElementRatio->GetNext()) {
$ratioId = $arRatio['ID'];
$arFieldsNew = Array(
'RATIO' => $coeff,
);
return CCatalogMeasureRatio::update($ratioId, $arFieldsNew);
}
}
);
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