As discussed, it would be useful to implement a consistent hook to modify a newly created entity.

Here is what needs to happen:

  • Modify the create() function of DrupalCommerceEntityController to call an alter hook (let's say hook_commerce_entity_create_alter()
  • Modify all the other controllers to properly call parent::create()

Comments

rszrama’s picture

Status: Active » Needs review
StatusFileSize
new6.61 KB

Voici. Test bot, ENGAGE!

rszrama’s picture

Status: Needs review » Fixed

Aaand, committed. Note that this module doesn't actually make use of the hook anywhere, but honestly I'm not sure that we actually have a core use case for it. The only one I could think of as a possibility was as a replacement for the hook in Product Pricing that lets us add the current cart order ID to a line item being used for product sell price calculation, but that really is a context sensitive alteration of the line item - and we won't have that context inside hook_commerce_entity_create_alter() itself. We could if we determined it was worth "hacking" the line item values so that the line item contains a property flagging the newly created line item as created for sell price calculation, but I'm not sure that's a better developer experience than just keeping the specific hook.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.