P
P
Pavel Bykov2019-02-21 00:13:08
1C-Bitrix
Pavel Bykov, 2019-02-21 00:13:08

How to update the coefficient of the unit of measure in the sales catalog?

Hello, I rummaged through the entire Internet, and so I could not find a clear, working answer, how to update, or how to add this ratio ...
When adding a product, the RATIO parameter does not work

CCatalogProduct::Add(
                        array(
                            "ID" => $ID,
                            "QUANTITY" => $product->amount,
                            "RATIO" => $product->amount
                        )
                    );

It also doesn't work when updating.
CCatalogProduct::Update($ID, ["QUANTITY" => $product->amount, "RATIO" => $product->amount]);

Tried the following methods and they don't work either:
\Bitrix\Catalog\ProductTable::update(19612, Array('RATIO' => 2));
CCatalogMeasureRatioAll::update(19612, Array('RATIO' => 2));
CCatalogMeasureRatio::update(5, Array('RATIO' => 2));

So how do you update, or add a coefficient?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Bykov, 2019-02-21
@mafof

I found the answer to my question, in order to change this coefficient, you need to add it at the beginning through the function:
The above code will give us the necessary ID to update the coefficient through the function:
If there is a coefficient ID, it can be found through the function:

CCatalogMeasureRatio::getList(Array(), array('IBLOCK_ID' => 12, 'PRODUCT_ID' => 27387), false, false);

R
Roman Gritsuk, 2019-02-21
@winer

ProductTable::update must return an object of the Result class. See what's in it

$updateResult = \Bitrix\Catalog\ProductTable::update(19612, Array('RATIO' => 2)); 

print_r($updateResult);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question