Answer the question
In order to leave comments, you need to log in
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:
I slightly modified it so that it takes the quantity from the user field.
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);//привязываем к сделке
}
Answer the question
In order to leave comments, you need to log in
The REST documentation has a crm.deal.productrows.set method that does this, but there is no such mention in the developer documentation
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 questionAsk a Question
731 491 924 answers to any question