Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

Version 1 Current »

Currently, when changing order item contents during order processing in OrdersEventHandler class such code is used:

$order_item->SetDBFieldsFromHash($rec);
$order_item->SetId($rec['OrderItemId']);
...
$order_item->Update();

Problem with this approach is that inside OnBeforeItemUpdate, that is called during update the original field values of the object are not taken from database and default values are used. This way any code checking that field value was changed using $object->GetOriginalField method will always think that field is changed, but it's not true in majority of cases.

Solution

Use this code instead.

$order_item->LoadFromHash($rec);
...
$order_item->Update();

Related Tasks

  • No labels