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.
I need to make a list of popular (most buy) products. I create a view which displays Ordered Products and use aggregation to sort the products based on number that the products has been sell in past. I have there available all node basic infomations, product options but I miss any custom fields (like image field).
I try to use any possible relations that is available but without success. I think there should be one relation that make relation between product and node fields.
Thanks for any advice or solution.
Comment | File | Size | Author |
---|---|---|---|
#23 | 1565484-views-product-custom-fields-23.patch | 1.86 KB | longwave |
#20 | 1565484-views-product-custom-fields.patch | 2.23 KB | longwave |
#15 | custom_fields_not_available-1565484-15.patch | 2.24 KB | g089h515r806 |
#5 | custom_fields_not_available-1565484-5.patch | 1.86 KB | g089h515r806 |
Comments
Comment #1
ckngUpdated the title to better reflect the issue, and marking as bug.
Custom content type fields defined under Product content type or other product classes are not available within the Orders type views. This should be available as part of "Order: Products" relationship.
Comment #2
ckngShould be Orders/Ordered Products type views.
Comment #3
ckngThis is SQL from an Order type views with Order: Products relationship defined. Fields in volunteer_ticket content type are not available for views field/filter. What could be the problem?
Comment #4
Jere Toivanen CreditAttribution: Jere Toivanen commentedIs there any solutions?? anyone?? i want my imagefields/filefields to ordered products - page.
Comment #5
g089h515r806 CreditAttribution: g089h515r806 commentedHere is a patch which solve this issue on our project.
Comment #6
SilviuChingaru CreditAttribution: SilviuChingaru commentedThis patch definitely shoul be commited. I made a litle module that is using hook_views_data_alter to implement this relationship. I think there is a problem with this patch also:
For anonymous users I get:
I'll dig in a little and see what causing the problem.
Comment #7
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #8
SilviuChingaru CreditAttribution: SilviuChingaru commentedThe patch is great, the problem was: #1785434: Ubercart is not implementing the foreign keys setting correctly in schema
The implementation of 'nid' field, according to node.views.inc from views module should be like this:
Also, I think that the product node should be implemented only as a relationship and $data['node']['table']['join']['uc_order_products'] should not be defined in uc_order.views.inc.
Comment #9
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #10
g089h515r806 CreditAttribution: g089h515r806 commentedI agree that "$data['node']['table']['join']['uc_order_products']" should be removed. It is useless.
But it is added by module mainterner.
Comment #11
g089h515r806 CreditAttribution: g089h515r806 commentedThe code was copied from Views Core(views\modules\comment.views.inc) :
I only made a little change to fit ubercart's requirement.
I do not think that it is nessesary to add such code:
Maybe 'views_handler_filter_numeric' already include "'click sortable' => TRUE,".
I mean that if the handler is 'views_handler_filter_numeric' , the the default value of 'click sortable' is TRUE.
If you still think that it is nessesary to add more info to it, you could submit a patch to Views Core, if the patch accepted by views core.
I could copy it again ^_^
Comment #12
SilviuChingaru CreditAttribution: SilviuChingaru commentedMy suggestion was copied from Node fields definition in Views Core so is no need to patch views only to modify this patch. Take a look in views/modules/node.views.inc for nid field:
Comment #13
longwaveIf you think $data['node']['table']['join']['uc_order_products'] should be removed, please post a patch. Quoting code is fine for discussion, but it is much easier to review and be sure of your full set of changes if you post patch files.
Comment #14
g089h515r806 CreditAttribution: g089h515r806 commented$data['node']['nid'] is diferent with $data['comment']['nid'] .
$data['node']['nid'] does not have 'relationship', nid is a normal property field of node.
$data['uc_order_products']['nid'] is more similar with $data['comment']['nid'].
At here $data['comment']['nid'] is a good example to follow.
We do not need to duplaicate the defination of $data['node']['nid'] at ['uc_order_products']['nid'] , it already defined in $data['node']['nid']. At ['uc_order_products']['nid'] and $data['comment']['nid'], we reference the defination of $data['node']['nid'] by using 'relationship'.
Comment #15
g089h515r806 CreditAttribution: g089h515r806 commentedLatest patch. works very well.
Comment #16
g089h515r806 CreditAttribution: g089h515r806 commentedI have removed
['table']['join'] could only pull a few fields, not all fields of node. Maybe only the fields from {node} table.
By using 'relationship', we could pull all node fields after we add a "Ordered product: Node" relationship.
If user already using fields provided by " $data['node']['table']['join']['uc_order_products'] " and "$data['uc_orders']['table']['join']['uc_order_products']". They will get a PDO error after apply "custom_fields_not_available-1565484-15.patch".
The correction is very simple:
add the relationship, and edit the fields again, the error will disappear.
Comment #17
g089h515r806 CreditAttribution: g089h515r806 commentedchange status to needs review.
Comment #19
longwave#15: custom_fields_not_available-1565484-15.patch queued for re-testing.
Comment #20
longwaveThis is the same as #15 except with some minor changes to the text.
This works well for me, but I also do not want to break existing Views if possible. Can we include both the automatic joins and the manual relationships?
Comment #21
g089h515r806 CreditAttribution: g089h515r806 commentedYes, we do not need to remove the code of "['table']['join']" in Drupal 7. Include both of them still works very well.
It will be very unfriendly if user get a PDO error after they update to latest code.
Just add a comment to remind that the code of "['table']['join']" will be removed in Drupal 8. I think this will be a little better.
Comment #22
longwavePatch needs work based on #21
Comment #23
longwave@g089h515r806: If you can confirm this works for you with no issues, I think this is ready to be committed.
Comment #26
longwave#23: 1565484-views-product-custom-fields-23.patch queued for re-testing.
Comment #27
g089h515r806 CreditAttribution: g089h515r806 commentedIt works very well.
Comment #28
longwaveCommitted #23, thank you for working on this.