Answer the question
In order to leave comments, you need to log in
How to correctly transfer the coefficient of the unit of measurement of goods from 1C to Bitrix?
There is a product electrodes, the unit of measure is tons, the quantity in stock is 0.02 tons. In a pack 0.005 tons. "Coefficient of the unit of measurement" - is set equal to 1. A lot of questions on this topic.
is it the "Unit Factor" in the upload?
<БазоваяЕдиница Код="168 " НаименованиеПолное="Тонна">
<Пересчет>
<Единица>168</Единица>
<Коэффициент>1</Коэффициент>
</Пересчет>
</БазоваяЕдиница>
AddEventHandler("iblock", "OnAfterIBlockElementUpdate", "OnAfterIBlockElementUpdateHandler");
function OnAfterIBlockElementUpdateHandler(&$arFields) {
\Bitrix\Main\Loader::includeModule('catalog');
// проверяем единицы измерения, если == тонны (ID=>7), то изменяем коэфициент с 1 на 0.005
if (CModule::IncludeModule("sale") && CModule::IncludeModule("iblock")) {
$db_propss = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], array("sort" => "asc"), Array("CODE" => "CML2_BASE_UNIT"));
if ($ar_propss = $db_propss->Fetch()) {
$EDINICA_IZMERENIA = intval($ar_propss["DESCRIPTION"]);
}
if ($EDINICA_IZMERENIA == 7) {
$r = CCatalogMeasureRatio::getList($arOrder = array(), $arFilter = array("PRODUCT_ID" => $arFields["ID"]), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array());
if ($ar_r = $r->GetNext()) {
if ($ar_r[RATIO] != '0.005') {
$db_res = CCatalogMeasureRatio::update($ar_r["ID"], array("RATIO" => 0.005));
}
}
}
}
}
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