Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using a Views Calc Table to display Ubercart orders, the dblog would contain errors about invalid SQL syntax related to this part of the query:
AND (node.nid IN (,,,,,,,,,,,,,,,,,,,,,,,,))
The error is because the view doesn't involve nodes, it involves Ubercart orders. The attached patch changes two lines of views_calc_table.inc to not assume the node table and node ids when calculating subtotals. Instead it uses the view's base_table and base_field members (which are "node.nid" for nodes and "uc_order.order_id" for Ubercart orders).
I built the patch against 6.x-1.3, and it applies cleanly to 6.x-1.x-dev (2009-Nov-07).
Comment | File | Size | Author |
---|---|---|---|
#5 | views_calc_1020936_5_base.patch | 2.69 KB | miro_dietiker |
#4 | views_calc_1020936_2_base.patch | 2.48 KB | miro_dietiker |
#1 | views_calc_use_base_field.patch | 906 bytes | mikec |
Comments
Comment #1
mikec CreditAttribution: mikec commentedComment #2
3dloco CreditAttribution: 3dloco commentedThanks mikec your patch worked for me!
Comment #3
basvredelingWorked for me too, not for ubercart stuff but for time_tracker entries. If you create a view for something besides nodes. say: node revisions, users or taxonomy terms, the entry id isn't "nid" either. This patch should work for every alternative field id for which a views result is generated.
For the real nitpickers out there, the nomenclature in the code should be adapted likewise. So instead of a $nid[] array, a $base_field[] array (or something like it) should be populated.
Thanks mikec.
Comment #4
miro_dietikerI duplicated this by
#776848: Calculate subtotals for non-node views, e.g., Ubercart orders
Providing patch that adds it a little more consistent.
Comment #5
miro_dietikerCommitting attached patch.