I
I
IliaMal2021-06-04 10:58:24
1C-Bitrix
IliaMal, 2021-06-04 10:58:24

How to set custom order properties (Bitrix\Sale\Order, getPropertyCollection())?

Hello.

I am implementing the "Quick Order" functionality for all items in the cart, there is a problem with filling in a custom property when creating an order.

I need to add a property informing that the order is fast.
60b9dc0ec19ae598934399.png

The documentation describes the methods, but with their help I can not achieve the desired result.
When trying to get a property like this $propertyValue = $collection->getItemById($id);or like this

$propertyValue = $collection->getItemByOrderPropertyId($propertyId);
$propertyValue = null()
If using
$propertyValue = $collection->getItemByIndex($index);
$propertyValue->setField('VALUE', 'Y');

then the object for some reason receives another property (with the smallest sorting) and writes to it
60b9dd101c0e6079509052.png

. How can I fill in the desired property?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tgarl, 2021-06-04
@IliaMal

So?

$propertyCollection = $order->getPropertyCollection();
foreach ($propertyCollection as $property) {
  if ($property->getField('CODE') == $code) $property->setValue('Быстрый заказ');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question