When we use Views field Order: Edit/Delete Link access permission for order is checked, but only by order_id and uid. I am adding order status to allow access hooks based on order status, for example to deny edit completed orders.

Comments

honza pobořil’s picture

Status: Active » Needs review
StatusFileSize
new2.52 KB
rszrama’s picture

Status: Needs review » Needs work

It would probably be better for us to just do a complete commerce_order_load() there. I'm not sure why we decided to make the pseudo order object, but if I'm not mistaken, by the time these links are being rendered, Views will have already loaded the entire order object into the static entity cache. Therefore, doing the full load here shouldn't be a performance hit.

Any chance you can confirm my suspcision?

honza pobořil’s picture

Status: Needs work » Needs review
StatusFileSize
new2.58 KB

I tried both variants - with pseudo entity and with entity load. In the experiment both codes were similar performance (execution time and memory usage), so your opinion is true. Here is patch.

By the way, if base table for view is not commerce_order, order entities wouldn't be loaded in view, so edit link load them fot him self and performance could be different.

chris matthews’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 6 year old patch in #3 does not apply to the latest commerce 7.x-1.x-dev and (if still relevant) needs to be rerolled.