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);
}
}
);