W
W
who_love_bx2020-08-06 15:01:01
1C-Bitrix
who_love_bx, 2020-08-06 15:01:01

How to add a product to the deal, to the existing ones, through the "Random PHP code execution" activity, and not overwrite it?

Good afternoon. We have a boxed Bitrix portal. After the transaction is closed, it is necessary to record the goods in the transaction. I take the quantity from the custom field in the deal. I found information in the developer's documentation on how to add products:
5f2bed2cb46ff187883857.png
I slightly modified it so that it takes the quantity from the user field.
5f2befff9d1e9017189488.png
But my problem is that it always overwrites the product, and does not add to the existing one.
The REST documentation has a crm.deal.productrows.set method that does this, but there is no such mention in the developer documentation

if (\Bitrix\Main\Loader::includeModule('crm')) 
{ 
    $rows = array(); 
    $rows[] = array( 
         'PRODUCT_ID' => '232', 'QUANTITY' => '{=Document:UF_CRM_1587105903}',   'PRICE' => 5, 
    ); 
    CCrmProductRow::SaveRows('D', {=Document:ID}, $rows);//привязываем к сделке 
}

Tell me how you can solve such a problem and where it is possible to have a description of the API, not REST.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Edward, 2020-08-08
@Drayde

The REST documentation has a crm.deal.productrows.set method that does this, but there is no such mention in the developer documentation

Reread the description of the crm.deal.productrows.set method
Commodity items - an array of the form array(array("field"=>"value"[, ...])[, ...]), where the "field" can take values ​​from those returned by the crm.productrow.fields method.
Items of the transaction, existing before the method call, will be replaced by new ones. After saving, the transaction amount will be recalculated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question