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.
Hi, is there already an integration with the Views module?
I'd like to make a view with roles in the coloumns and products in the rows, so that the store administrator can manage several price lists on one table.
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#55 | views_integration-646724-55.patch | 7.12 KB | SeanA |
#52 | uc_price_per_role_views_integration-646724-52.patch | 7.61 KB | rjlang |
#49 | uc_price_per_role_views_integration-646724-48.patch | 7.62 KB | rjlang |
#47 | uc_price_per_role.views_.inc_.txt | 1.55 KB | allexx |
#47 | uc_price_per_role_handler_field_price.inc_.txt | 298 bytes | allexx |
Comments
Comment #1
p4trizio CreditAttribution: p4trizio commentedI found this...
http://views-help.doc.logrus.com/help/views/api
but I'm not an expert. Any advices how to begin?
Comment #2
kevinquillen CreditAttribution: kevinquillen commentedDoes this have no views integration? Pretty integral I'd think to have it, so you could have a Price field that feeds off of uc_price_per_role based on a rid argument(s) from the user object.
Comment #3
p4trizio CreditAttribution: p4trizio commentedI had to find somewhere else. Just solved it using uc_discount framework (patched) and cck, created as many cck field for the prices and assigned them with conditional actions using triggers provided by discount framework
Comment #4
longwaveThere is no Views integration at present. I can see use cases for providing VIews fields for each enabled price role and an extra field that dynamically shows the sell price for the current role, but have no time or inclination to implement this at present. Patches are welcome, however!
Comment #5
Stevo_0 CreditAttribution: Stevo_0 commented=(
Ill reiterate what was said above, and say its fairly critical to have views integration.
But I can also say I appreciate how much time and effort can go into building these modules (having done only some basic work in this area).
Comment #6
kevinquillen CreditAttribution: kevinquillen commentedI would, but I don't know how to write views plugins like I used to for Views 1. Wish I had time to learn.
Comment #7
kcyarn CreditAttribution: kcyarn commentedI need this functionality as well. I plan to start working on the Views integration this weekend. Anyone want to collaborate?
Comment #8
ambereyes CreditAttribution: ambereyes commentedI am interested in this functionality as well. I am willing to help out, maybe we can start with the existing functionality in uc_views.
How far did you get kcyarn?
Comment #9
ambereyes CreditAttribution: ambereyes commentedSo in scratching my own itch I used views_customfield plus the patch from #911110: Views arguments in PHP code field and borrowed code from all over the place (uc_atrribute, uc_views, uc_price_per_role) to create my Sell Price field as seen in the two attached images.
YMMV ... [edit] and oh yeah .. plus uc_multibuy :-)
Comment #10
adam_b CreditAttribution: adam_b commentedsubscribe
Comment #11
ColinMctavish CreditAttribution: ColinMctavish commentedsubscribing
Comment #12
Cablestein CreditAttribution: Cablestein commentedI'm getting by with the following code, thanks to ambereyes help, using in Views custom PHP field:
Don't know if I need anymore, but this is doing fine for me so far.
Comment #13
kruser CreditAttribution: kruser commented@Cablestein - Thanks for the nice snippet
I added my own twist to show the role price based on the current user's role.
Comment #14
jonathan_hunt CreditAttribution: jonathan_hunt commentedHere is a start at Views integration. It needs a handler(?) to select which Role to show.
Comment #15
djdevinMaybe a filter that has:
( ) User's current role
( ) Role 1
( ) Role 2
( ) Role 3
Comment #16
djdevinHere's a working views integration w/handler, rolled against master...should allow a specified role-specific price to display/filter in views.
Comment #17
scottrigbyChanging title so it doesn't get lost with the other gazillion contrib issues by the same title
Comment #18
SeanA CreditAttribution: SeanA commentedNot quite there yet. This doesn't need to *filter* on role prices, it needs the ability to add *fields* for the various role prices. For example, I'd like to build a single admin view that shows the sell price along with the prices for each role for each product.
Also, instead of the generic 'views_handler_field_numeric', it would be nice have the option to use 'uc_product_handler_field_price' to display the price value with the standard Ubercart formatter.
Comment #19
djdevinNot sure if we can do that easily. Views doesn't have very good support for a variable number of columns.
I did actually try it with uc_product_handler_field_price but ended up having a lot of issues using it. I'll try it again...
Comment #20
AllyMediaGroup CreditAttribution: AllyMediaGroup commentedApplied patch from djdevin It said failed on hunk #1 and gave a rej file in the folder. I have attached the reject file of the module
that I have tried to patch. And I now realize after reading the post by Sean A. He is correct I don't need to filter by the price per role, I need the fields that show on the product page to be displayed on a custom view for bulk operations to be able to make the change to the price per role fields.
Comment #21
djdevinPatch was for 6.x-dev, not 6.x-1.1.
Comment #22
AllyMediaGroup CreditAttribution: AllyMediaGroup commentedOkay I applied the patch to the 6.x-dev version and I still get the same message. Here is the message from terminal
ubuntu@ubuntu:/media/drive/uc_price_per_role$ patch -p0 < 646724-uc_price_per_role-views.patch
patching file b/includes/uc_price_per_role_vhf_role.inc
patching file b/uc_price_per_role.module
Hunk #1 FAILED at 617.
1 out of 1 hunk FAILED -- saving rejects to file b/uc_price_per_role.module.rej
patching file b/uc_price_per_role.views.inc
Comment #23
SeanA CreditAttribution: SeanA commented@AllyMediaGroup: you can probably just edit the file and add those lines by hand.
Eventually I will likely want the same thing as AllyMediaGroup: after getting this Views integration going, it would be super-duper to have a VBO handler as well. Haven't had time to work on either of these tasks myself yet.
Comment #24
AllyMediaGroup CreditAttribution: AllyMediaGroup commentedI have found that Ubercart Product Actions @ http://drupal.org/project/uc_product_actions does everything I need except I need to add the role pricing to the view that I created for bulk editing of orders that I have. It has the VBO for cost, list, price and weight modify. So I was going to add to it the VBO for the role pricing. But I need to be able to add the fields to the view for the role pricing so I can bulk update the pricing using the Ubercart Product Actions.
Comment #25
SeanA CreditAttribution: SeanA commentedYes, that's my plan as well. But a VBO handler will be need to be written to accomplish that. It should probably be separate from Product Actions though.
Comment #26
AllyMediaGroup CreditAttribution: AllyMediaGroup commentedYour probably right, I just don't know how to do the VBO handler separate from the Product actions. I figured that it could be added to the product actions since it has to do with products. If you don't use the price per role then it has nothing to pull from the database. I believe that you can set it so just not show if it is not there, but I am limited in my coding so, I am not sure. So once we have the views integration done to get the editable fields into views then we can either add it to the existing module set to NULL if not available so it won't create any errors.
Comment #27
Cablestein CreditAttribution: Cablestein commentedI'm still using this snippet... but now I'm I need to render the price properly with ubercart theme price function. How do I call that? theme_uc_price() doesn't fully work?
Comment #28
SeanA CreditAttribution: SeanA commentedCablestein, I believe you want to use uc_price($value) or possibly uc_price($value, $context). It's not very well documented, but if you look thru Ubercart or contrib code (such as uc_price_per_role.module), you can find examples of how to set up the $context array.
see also http://api.ubercart.org/api/function/uc_price
Comment #29
AllyMediaGroup CreditAttribution: AllyMediaGroup commentedI have found a way to pull the fields into views for Price Per Role, using a variation to Cablestein's snippit . Originally it pulled all three role prices into one column that I have set in my site. I found the way to do this using the Customfield: PHPcode. As follows:
Where the rid=5" is the role id column in the uc_price_per_role_prices table. This will be different depending on the roles that you have on you site. If you do not include the rid it pulls all the prices for the nid into the same column. I created three custom code fields so that they show separately from one another. One for each role that has custom pricing. Now I just need to create the VBO for updating the pricing for the role prices and my customer will be happy.
Comment #30
djdevinThis will work, but is very costly, ie. for each row you have another query. A view of 500 products = 500 queries instead of 1 or 2.
Creating a field handler using views_handler_field_prerender_list is probably the best way to go in the long run.
Comment #31
fonant CreditAttribution: fonant commentedPatch in #16 worked quite well for me, so I could list products with a role-specific price for a given role. It might be worth tweaking the filter titles to make them a bit clearer as being from price_per_role module?
Comment #32
goodeit CreditAttribution: goodeit commentedI am really close to having a working D7 solution for this. However, my nodes are duplicated as many times as there are role prices for that item.
The db query is returning an extra row for each separate role price in the table. Does anyone know how to bring all of the role prices in on one row? I already have correct role price selection and display worked out.
I am looking into views_handler_field_prerender_list to see if that is a better handler to extend (currently I am using views_handler_field_numeric). However, I appear to be having the same duplication issue there as well.
I'm also concerned that modifying the data after the query will cause the pager to be off (see "Updates" section at http://capellic.com/blog/cure-duplicate-nodes-in-a-view for a description of what I think will happen).
When(/if) this gets worked out, I will explain how I did it. A backport to D6 should be very straightforward, as I am still using Views API v2.
Comment #33
goodeit CreditAttribution: goodeit commentedOK, I have a very rough version of this working, I think. It only shows the "correct" price for the current user, as determined by uc_price_per_role. It should be trivial to add an option to display all role prices for each item.
First, add these lines to uc_price_per_role.info:
Then, add this to uc_price_per_role.module:
Then put the two files I've attached in a subfolder of uc_price_per_role called includes (make sure they are named uc_price_per_role.views.inc and uc_price_per_role_handler_prerender_list.inc - with no extra _s or .txt)
There may be a few other small changes I have missed, so let me know if you encounter any problems with it.
I would really appreciate any feedback, and like I said, it should work without needing many changes on D6.
Comment #34
SeanA CreditAttribution: SeanA commentedThanks for posting your code. Testing.
Comment #35
SeanA CreditAttribution: SeanA commented@goodeit, yes, maybe you missed something, it's not working for me: "Notice: Undefined property: stdClass::$_field_data in uc_price_per_role_handler_field_prerender_list->render() (line 39 of uc_price_per_role_handler_field_prerender_list.inc)" and the same on line 42, and of course the role prices aren't showing up in my View.
If possible can you post a diff instead? That would make it easier to patch and test this, and avoid missing some changes.
Comment #36
goodeit CreditAttribution: goodeit commented@SeanA: Here's a diff from 7.x-1.x-dev to my current production code. I'm not sure it will fix the problem you're experiencing though :/ Note that it may have a few other miscellaneous changes in it unrelated to Views integration.
Comment #37
zviryatko CreditAttribution: zviryatko commentedthx, work fine (:
Comment #38
Ricky999 CreditAttribution: Ricky999 commentedHi, i'm trying Goodeit Price per Role solution to use it with editView but it seems doesn't work.
My error is:
Error: handler for uc_price_per_role_prices > price doesn't exist!
can u help me?
Comment #39
goodeit CreditAttribution: goodeit commented@zviryatko: Can you give some details of what is working for you? Are you using my patch, the module I posted, or someone else's code? What version of Drupal and views are you working with?
@Ricky999: the code I posted is for D7. I unfortunately don't have time to port it back to D6 at this time, but as I said, it should be pretty straightforward. Looking at existing views field code is a great place to start.
Comment #40
Ricky999 CreditAttribution: Ricky999 commentedI'm trying for D6 but nothing.....could someone help me?????I need to set Retailers in Edit View
Comment #41
Ricky999 CreditAttribution: Ricky999 commentedCould anyone have code for D6? I need to integrate my roles in EditView
Comment #42
goodeit CreditAttribution: goodeit commented@Ricky999, please stop changing the issue parameters. It's fine to ask for help, but more than one post in a row is not necessary.
Comment #44
silverwing CreditAttribution: silverwing commented@Ricky999, The users are working on this issue for a specific version of the module. If you still need help, please open a new issue. Continuing to change versions and components and curse at them will only irritate the people you are asking for help, but can also lead to your account being blocked.
Comment #43 unpublished.
See this issue for the webmaster request for our involvement.
~silverwing - drupal.org site maintainer
Comment #45
DenimTornado CreditAttribution: DenimTornado commentedNice! It's works for me too! Thx!
Comment #46
DanZ CreditAttribution: DanZ commentedCan anyone make a working patch out of #33?
Comment #47
allexx CreditAttribution: allexx commentedTo contionue goodeit work, I'd like to share solution for exposed filter.
I tested with between condition.
uc_price_per_role.info add:
files[] = views_handlers/uc_price_per_role.views.inc
uc_price_per_role.module add:
function uc_price_per_role_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'uc_price_per_role') . '/views_handlers',
);
}
Comment #48
DanZ CreditAttribution: DanZ commentedPlease leave this on 7.x-1.x-dev. If you would like to do this for 6.x, please make a new issue. Also, please submit it as a patch. See https://drupal.org/project/uc_price_per_role/git-instructions for instructions on making a patch.
Note that there is no active maintainer for 6.x. If you would like to help, please reply to #1899398: Maintainer needed for 6.x-1.x.
This issue is planned for 7.x-1.1. I just have many other projects ahead of it. It would happen sooner if someone made a patch.
Comment #49
rjlang CreditAttribution: rjlang commentedPer #48, attached is a patch against 7.x-1.x-dev.
This is a little different from goodeit's #36. It creates a new field in the Product group, "Particular role price," that lets you choose the role to display in the view handler settings, and there is a special choice for "Applicable price" that displays the relevant price for the viewing user. So, for example, you could make a View with columns like this:
Retail price -- Wholesale price -- Your price
Each column would be the same field, but with different field handler settings to chose the relevant role and the last column is "Applicable price."
The Views integration also includes field definitions for role ID and role price from the uc_price_per_role table.
Comment #50
Poieo CreditAttribution: Poieo commented@rjlang - I've tried out your patch and everything works great, except that I can only get the first 'price per role' to display in a view. The remaining products in the view are blank. Seems like a foreach issue or something...
edit: Only the first price shows when you're viewing the default price. i.e. - you're not logged in with a role. When logged in with a role the prices for all products in the view are visible.
Comment #51
rjlang CreditAttribution: rjlang commentedAh, the edit was helpful. Thanks, I can reproduce this. Will look into it,
Comment #52
rjlang CreditAttribution: rjlang commentedOK, found it. (D'oh. Headsmack.) Attached is a revised patch against 7.x-1.x-dev.
If you've previously applied the patch from #49, just change the last 4 lines of uc_price_per_role_handler_field_role_price.inc from
to
Comment #53
Poieo CreditAttribution: Poieo commentedWorks great. Thanks! Let's see if we can get it committed.
Comment #54
PetarB CreditAttribution: PetarB commentedCan anyone please provide the 'patched' file here. I can't do patches sorry! :(
Edit: well I should say that I tried, but it's not working, and throwing up 'hunk failed' errors in the patching.
Comment #55
SeanA CreditAttribution: SeanA commentedHere's a re-worked patch, it's the same content as in #52, just formatted so that 'git apply' works cleanly with it. I haven't tried out the functionality yet, but thank you for working on this. Changing status back to 'needs review'.
Comment #56
PetarB CreditAttribution: PetarB commentedI'm still have trouble applying the patch with this one (OSX + Terminal). Can you post the patched module?
Comment #57
PetarB CreditAttribution: PetarB commentedJust got a working version of this to test. Works very nicely in views now, with good flexibility for different requirements. As far as the user experience goes (I'm not coder) it seems ready to go for a commit.
Comment #58
DanZ CreditAttribution: DanZ commentedSorry, I've been away (moving house). Thank you for your work on this.
Comment #59
SeanA CreditAttribution: SeanA commentedIt seems to be working well so far. In my demo store there are just 2 products and price-per-role is set up for 'distributor' and 'admin' roles. Will continue testing.
#49 says: "The Views integration also includes field definitions for role ID and role price from the uc_price_per_role table." When these fields are added to a View, multiple rows of some products appear:
Are these extra fields needed? They Role ID might be useful, but I can't tell if it's working correctly or not. =D The 'Role price' field seems redundant. Maybe get rid of it and rename 'Particular role price' to just 'Role price'? (Shorter help text for that field: "A specified role price as determined by UC Price Per Role.")
Comment #60
rjlang CreditAttribution: rjlang commented@SeanA #59: The difference between Role Price and Particular Role Price is that the latter ALWAYS returns exactly one row, while the former only returns a row if there's a price for that role, or multiple rows, if you've defined multiple role prices for a product.
So what's the use case for the Role Price field? In combination with a filter on Role ID, you could make a view that shows you ONLY the products for which you've defined a particular role price.
I can't think of a use case where you'd want to use both Role Price and Particular Role Price together, as you've done in your example.
The definitions for fields for Role Price and Role ID are there under the philosophy of "let's expose any field that might be of interest to give users maximum flexibility in building their views." The definition for Particular Role Price field is there under the philosophy of "this is what most users probably actually want to see."
HTH,
Robert
P.S. To tell if Role ID "is working correctly", see if the listed Role ID (e.g., 4) matches the price you've set for your product (e.g., "Daily Subscription") for that role. Looking at your screen shots, it looks like it is.
Comment #61
SeanA CreditAttribution: SeanA commentedSure, I figured that out, but what confused me was the 2 extra identical rows in the second screenshot... using 'Distinct' on the query gets rid of the extra rows, so that was a basic Views issue.
After more testing logged in with various roles it looks like everything is working very well. I'll try backporting the patch to 6.x.
Comment #62
DanZ CreditAttribution: DanZ commentedI should have time to review the 7.x code this weekend.
Comment #63
esquareddesign CreditAttribution: esquareddesign commentedFor the life of me, I can not get this patch to work. I had to patch the file manually. Am I missing something?
Comment #64
sirish.ayyagari CreditAttribution: sirish.ayyagari commented:uc_price_per_role >$ patch -p1 < views_integration-646724-55.patch
patching file uc_price_per_role.info
Hunk #1 FAILED at 4.
1 out of 1 hunk FAILED -- saving rejects to file uc_price_per_role.info.rej
patching file uc_price_per_role.module
patching file views/uc_price_per_role.views.inc
patching file views/uc_price_per_role_handler_field_role_price.inc
Comment #65
tj99ay CreditAttribution: tj99ay commentedAnyone been able to use #13's solution but for Drupal 7? I tried this variant:
but got this error:
Notice: Undefined variable: nid in __lambda_func() (line 1 of /etc/drupal/7/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc(131) : runtime-created function).
Cheers
Comment #66
SeanA CreditAttribution: SeanA commentedsirish.ayyagari, you have to examine the contents of the .rej (reject) file to see where the problem is. This patch creates new files... are you using 'patch' properly? In any case, you should prolly use 'git apply' instead.
https://www.drupal.org/project/uc_price_per_role/git-instructions
Comment #67
SeanA CreditAttribution: SeanA commentedtj99ay, does that (#13) accomplish something that can't be done with the current patch? It's been a while since I looked at this.
Comment #68
tj99ay CreditAttribution: tj99ay commentedSeanA, how rude of me not to reply. Sorry I can't remember now, so long ago. I was trying to find a way to allow my client to edit lots of product prices at once via a spreadsheet then import (they are used to doing this), but as we used UPPR it stuffed our plans a bit. Still trying to find a way though, but it looks like we'll be needing to create a custom module at some point.
Comment #69
tgyuksel CreditAttribution: tgyuksel as a volunteer and commentedfor View entegration display Price or Sell Price ... If select display price eevrybody will see price ( price = default price as user per role price ) ... don't select SELL PRICE .... For per role price in view select DISPLAY PRICE ...
Comment #70
tgyuksel CreditAttribution: tgyuksel as a volunteer and commentedArkadaşlar view ile per role price seçilmiş üyelere göre otomatik görüntületmek için view düzenlerken DIPLAY PRICE seçiniz ! Eğer SELL PRICE seçerseniz per Role price tek fiyat gösterecek ve çalışmayacaktır.