Answer the question
In order to leave comments, you need to log in
How to bulk change the coefficient. units measurements for goods by decimal value?
On a random page, I made the following code:
if (CModule::IncludeModule("catalog")) {
$get_list = CCatalogProduct::GetList(array('SORT'=>'ASC'), array('MEASURE'=> 8, "%ELEMENT_NAME" => "Портьера"));
while($kg_result = $get_list->GetNext()) {
$ed_list = CCatalogMeasureRatio::GetList(array(), array('PRODUCT_ID'=>$kg_result['ID']), false, false, array());
while($ed_result = $ed_list->GetNext()) {
CCatalogMeasureRatioAll::update($ed_result['ID'], array('PRODUCT_ID'=>$kg_result['ID'], 'RATIO' => 0.5));
}
}
}
Answer the question
In order to leave comments, you need to log in
First you get the id-nicknames of the products for which you need to change the coefficient (as I understand it, this is your first request), then
\Bitrix\Main\Loader::includeModule('catalog');
$productIds = [323, 316];
$ratio = '0.5';
$iterator = \Bitrix\Catalog\MeasureRatioTable::getList([
'select' => ['ID'],
'filter' => ['PRODUCT_ID' => $productIds]
]);
while($row = $iterator->fetch()) {
\Bitrix\Catalog\MeasureRatioTable::update($row['ID'], ['RATIO' =>$ratio]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question