Problem/Motivation
On initial order creation/save, there is a hook_ENTITY_insert to update the order number. This poorly performs on a site that is taking lots of order in short order, pun intended.
Proposed resolution
Add the order_number at entity load time, it will then get written to the DB on next save.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3015330_4.patch | 1.64 KB | khiminrm |
| #2 | 3015330.patch | 1.64 KB | heddn |
Comments
Comment #2
heddnComment #3
khiminrm commentedI’ve checked the patch. By using those patch, revision table do not have initial value of order_number, views show empty value for new created order_number. Also commerce_order_load_by_number() doesn’t work for new created orders.
Comment #4
khiminrm commentedRe-rolled patch to current dev version
Comment #5
rszrama commented@khiminrm So this needs to go back to needs work I guess?
Comment #6
rszrama commentedI'm going to won't fix this, as I don't see a feasible path forward after trying to make it work in a project w/ khiminrm. The biggest problem I see is that you don't actually know when the next save for the order will occur. This could leave you without an order number for quite some time, and it would certainly throw off the sequential ordering of numbers even worse than already occurs.
My recommendation would be to set the order number in a pre-save hook if this were an issue on a given client site. I think the actual implementation will need to vary per the site's specific needs.
Comment #7
rszrama commentedSorry, just converting this to a support request so all involved still receive credits for their research. Thanks, @all!