Saving a line-item object Can anybody explain me why the right way for programmatically saving a line item object with Drupal Commerce is the following one?

commerce_line_item_save($item);
entity_get_controller('commerce_line_item')-&gt;resetCache(array($item-&gt;line_item_id));


I wish to be smarter after knowing that.
That isn't the right way to save a line item. All that second line does is remove the item from the entity controller's static cache.

As CommerceLineItemEntityController::save() already manipulates the static cache directly to ensure the updated entity is in it, the second line is redundant. All it does is force unnecessary database usage if/when the same line item is loaded again in the same request.

This is all you need to create or update a line item:

commerce_line_item_save($item);


Remember that $item is an object, so doesn't need to be passed by reference as you mentioned in the comments.