Hey everyone,
I've been trying to modify Drupal Commerce's standard order view to allow the store admin to filter orders by:
1. Order creation date
2. Product SKU or name
But I can't seem to properly implement either of these as exposed filters.
For the order creation date, I've tried adding "Commerce Order: Created date" as an exposed filter, but the filter doesn't seem to work for me.
As for the SKU or product name, the goal is to allow the store admin to see only orders that contain a particular product. But I don't see either the SKU or the product name as available fields under "Filter Criteria".
Any ideas?
Thanks,
Ben
P.S. These filters might be handy to have by default on the Orders page.
Comments
Comment #1
hazaAbout the date filter, it seems to work fine for me, see there https://skitch.com/haza/fbegy/filter-date.png (I'm overriding the default orders view.)
Comment #2
hazaAnd about the SKU filter, you need to add a new relationship in views : Order: Line Items
This relationship then let you add an other relationship : Lien item: Product
And then, you can add the SKU filter to the views.
https://skitch.com/haza/fbe8m/orders-commerce-order-commerce-kickstart
Comment #3
bojanz commentedComment #4
BenK commentedJust wanted to confirm that Haza's instructions were excellent and helped me solve this. Thanks!
The issue with the date was that I needed to use both a "from" date and a "to" date.
And for the SKU, I needed those two relationships.
Thanks again for your help,
Ben
Comment #6
scotwith1tjust a note to add, if you have Date module enabled, choose the Date: Date (commerce_order) field to take advantage of Date module's power and not the Commerce module's filter.
Comment #7
joachim commentedThe way to do this would be to either:
a. add a dedicated column for the checkout time
b. add a Views relationship to the order revision table, joining on 'status' = 'checkout_complete' and get the timestamp from that.
Regarding http://www.bywombats.com/blog/01-24-2012/updating-completed-order-timest..., I don't think that rewriting the order timestamp with a Rule is really a solid enough solution.
Comment #8
joachim commentedMeant to reopen.
Comment #9
geek-merlineverything we need is in the order revision table so setting as dup of #804850: Integrate Order Revisions with Views.
Comment #10
joachim commentedThat doesn't actually give us everything we need. Once that's patch is in we'll have to add more here: we need to be able to hop from the order to a single revision *based on that revision's status*.
In other words, a custom relationship handler that implements a custom join like:
JOIN order_revision ON (id = id) AND order_revision.status = 'checkout_complete'.Comment #11
5n00py commentedYes, I confirm that we need additional views handlers! But now #804850: Integrate Order Revisions with Views is a blocker for this issue!
Just wait for closing revisions issue! After this we can start working on this issue!
Comment #12
5n00py commentedI'm looking for solution for this issue and no good result I found...
As in #7 ("b" solution) and #10 I tried to get checkout date via mysql joins.
In my situation i have order with few revisions with status = 'checkout_complete'.
That is problem for me because join gives me multiple rows for each order. And there is no transparent way to limit joined rows without GROUP BY operator.
Another question is: which of of revisions use to get checkout date? first? last? Which?
Simplified mysql query from views with additional join:
As for me better way is set creation date (or dedicated field) via rules when completing checkout.
rules actions can be replaced with hook implementations in commerce or custom module.
Comment #13
johnyeong commentedHi,
Thanks for your assistance. Just followed your steps. Solved most of my problems in creating a filter based on the product attributes.
However, I have a problem with my orders being duplicated. I checked, and found out that the duplication came from the Order: Line Items. Think you could help me out with that? Your assistance is most appreciated.
Thank you sir.
-John Yeong-
Comment #14
tmsimont commentedsome might find this useful: #2044231: Add "paid in full" datestamp to order along with "created" and "updated" -- not sure if my post is totally relevant to this one... but its definitely similar
Comment #15
rszrama commentedClosing this back out and linking to #2044231: Add "paid in full" datestamp to order along with "created" and "updated" where I've committed the rule to core that I used in my blog post. Joachim linked to this above, and I gave my two reasons for opting for this solution instead of something more robust in my linked issue there. Feel free to comment on it; the gist is the new rule is unobtrusive and a more comprehensive fix should be devised for Commerce 2.x.