Needs review
Project:
Ubercart Views
Version:
6.x-3.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Dec 2009 at 09:35 UTC
Updated:
12 Jun 2013 at 11:31 UTC
Jump to comment: Most recent file
Comments
Comment #1
madsph commentedNo unfortunately there is not. The field is from a database view that simply sums the quantity across all orders with out regard to order status.
I do however, think that you can use some of the standard views features (maybe combined with views_calc) to make your own sums on orders filtered on status.
Comment #2
marcus178 commentedWell I just spent about 3 hours trying to figure this out, even tried views_calc but not really got anywhere.
I'm sure it must be possible just to have a list of products with how many have been sold i.e the same as the products report that comes with ubercart, and from that I can add the other fields I require.
Comment #3
madsph commentedDo you have any experience with coding views code for drupal?
I think that is your best option at this point - I have tried various approaches but none with success. There is a views_groupby module, that in time should solve your problem, but right now they only support COUNT() not SUM().
If you feel like trying, I think it is relatively easy to make your own custom module, with every thing you need.
What you need to do is to:
1. Take a copy of
uc_views_marketing.2. From that copy remove everything except what relates to
uc_order_products_qty_vwin all files.3. Replace
uc_order_products_qty_vwto what ever you want in all files (to avoid name clashes withuc_views_marketing)4. Replace
uc_views_marketingto what ever you want in all files and filenames (again to avoid name clashes withuc_views_marketing)5. In your .install file change the way the db view is created:
Comment #4
marcus178 commentedI've done some coding so more than happy to have a bash at this, thanks for your guidance and I'll let you know how I get on.
Comment #5
marcus178 commentedThat was a lot easier than I thought it would be. I've created a new module called reports that only counts completed orders. I attached it for anyone else that needs a similar function. Thanks for your help.
Comment #6
madsph commentedGreat glad to help out, and thank you for posting your solution back for others to see.
Comment #7
marcus178 commentedSorry to reopen this but I could do with some help as I also need to include another order status in the results but can't seem to work it out, I'm afraid I'm not very god with sql. The status I'm trying to include is pos_completed. I have tried the following.
db_query("CREATE VIEW {uc_order_products_qty_sold} (nid,order_count_sold,avg_qty_sold,sum_qty_sold,max_qty_sold,min_qty_sold) AS SELECT `op`.`nid` AS `nid`, COUNT(`op`.`nid`) AS `order_count_sold`,AVG(`op`.`qty`) AS `avg_qty_sold`, SUM(`op`.`qty`) AS `sum_qty_sold`,MAX(`op`.`qty`) AS `max_qty_sold`, MIN(`op`.`qty`) AS `min_qty_sold` FROM {uc_order_products} `op`, {uc_orders} `order` where `order`.`order_id` = `op`.`order_id` and `order`.`order_status` in ('pos_completed') OR `order`.`order_status` in ('completed') GROUP BY `op`.`nid` ORDER BY `op`.`nid`");Comment #8
madsph commentedI thought you might want to do something like that, so I prepared the SQL to be easy to expand ;-)
The 'in' clause gives you the opportunity to write a list of valid hits for your field, so in stead of making an 'OR' you can simply add 'pos_completed' to the list, like this:
`order_status` in ('pos_completed', 'completed')
Comment #9
j0rd commentedI'm going to second this feature. It really only makes sense to create values on the `uc_order_products_qty_vw` for completed orders. Otherwise the numbers are not reflective of actual sales.
I know you can add new order_statuses in Ubercart at will, so there should be a configuration page, where the people can select which order_statuses they want in their query to count towards these sums.
I guess the problem on why you can't do this is because you `CREATE VIEW` in the .install file.
Here's what I did to hack this in:
You might have to do something like this for the other tables if you require this functionality.
Comment #10
j0rd commented@marcus178 you're module is great for those who only want to get simple order total reports with out all the rest of the functionality of uc_views.
I'd recommend removing the uc_views and views_slideshow dependancies from the .info file and adding this module to drupal.org so people can find it easy.
It would also be a good idea for uc_views to either absorb this module or remove it's dependancies for uc_views_marketting (since I don't think uc_views is actually required).
my two cents.
Decided to go with marcus' module instead, since it does what I need and nothing else ;)
Comment #11
ken hawkins commentedRealize this issue queue is quite old, however the small module by marcus178 in #5 is still perfectly valid and quite usable.
Marking as "needs review" in hopes of getting this considered for inclusion.