A
A
Andrey Elsukov2021-12-17 05:14:51
1C-Bitrix
Andrey Elsukov, 2021-12-17 05:14:51

Bitrix. Why doesn't getPropertyCollection see all properties?

After updating Bitrix from 18.1 to 20.5, an interesting problem happened:

$order = \Bitrix\Sale\Order::create(SITE_ID, $userID);

$order->setField('STATUS_ID', 'N');

$order->setPersonTypeId(2); // Физическое лицо

$propertyCollection = $order->getPropertyCollection();


$propertyCodeToId = array();

foreach($propertyCollection as $propertyValue){
    $propertyCodeToId[$propertyValue->getField('CODE')] = $propertyValue->getField('ORDER_PROPS_ID');
}

echo '<pre>'; print_r($propertyCodeToId); '</pre>';


This code allows you to get the properties of an order with the specified payer type.
The problem is that after updating the Bitrix, I do not get all the properties.
For example, a property with NAME with ID 40.
I looked in the database, in the admin panel. the property exists, is active, belongs to the payer type with ID=2 and is no different from the others that are displayed
Before the update, all properties were displayed

What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Elsukov, 2021-12-20
@Dropsen

Found a solution.
I don’t know if anyone will have such a problem, but the plan of action is as follows:
In new versions of Bitrix, there may be a glitch: in the list of order properties => property binding => delivery service, the selected elements are not visible. You need to make sure that everything you need is worth it.
Further, binding properties and calling the product must be AFTER adding the shipment and $payment->setField('SUM', $order->getPrice()); (when this method is applied, all related objects will be rebuilt).
After these actions, all properties became available again.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question