1

I need to run commerce_order_save() on several Orders in loop but without triggering any Rules.

Is that possible ?

5

It's possible, but the change would need to be sitewide (not just in the context of rules). You'd need to override the entity controller class used for commerce_product (which you could do with hook_entity_info_alter()), and re-implement its save() method so it doesn't invoke the entity hooks.

If that is undesirable (probably is), and you just need to update field values, you can use field_attach_update() instead, which will bypass the entity save process altogether:

$order->some_field[LANGUAGE_NONE][0]['value'] = 'foo';
field_attach_update('commerce_order', $order);

Other than those I don't think there's any way to accomplish it using the API.

1
  • I just need to update the content of a field and it needs to be saved in database. That's it. – Michal Przybylowicz Mar 9 '15 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.