A
A
Andrew2020-11-19 10:46:29
1C-Bitrix
Andrew, 2020-11-19 10:46:29

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</Коэффициент>
    </Пересчет>
</БазоваяЕдиница>

But, if I write <Coefficient>0.005Coefficient> with my hands, the "Unit of measurement coefficient" remains equal to 1 for the product.
If I manually change the "Unit of measurement coefficient" in the admin panel, everything works as it should, and the warehouse and basket work correctly.
1. Questions, what should this ratio look like in the download?
2. For a 1C nickname, I found such a manual, https://enote.cloud/inf/encyclopedia/kak-vesti-uch... is it suitable for him?

Thanks for the help!

in desperation, I already tried such a code (id for tons - 7), they and it does not work
Code
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 question

Ask a Question

731 491 924 answers to any question