Hierarchical Select for Ubercart attributes

Posts: 5
Joined: 06/26/2008

Hi all,

I'm the developer of the Hierarchical Select module. I'm currently going through the final things for version 3 of this module and I just bumped again into the "support for Ubercart attributes" feature request.

I know Ubercart has gained quite a lot of momentum, but I haven't used it myself yet. So, to gather info quickly I went to the IRC channel (thanks to cYu for answering my questions!), asking if there was a genuine need for Hierarchical Select support. I.e. does it make sense to have hierarchical UC attributes? It seems the answer is yes, since there are several requests for this kind of functionality.

However, this particular post learns me that UC currently has two separate entities, "attribute" and "attribute option". That's fine, but it doesn't allow for very flexible hierarchies. You can still use Hierarchical Select, but it will not be as significant an improvement as possible.

Suppose you have a "type" attribute and a "size" attribute. Type A can't have different sizes than type B, because UC doesn't allow you to define hierarchical attributes.
There are two missing links to hierarchical attributes:
1) There is no way to say that one attribute is a child of an attribute option, which is necessary if we want true hierarchies, as I just described. This must be supported both in the code and in the admin UI.
2) UC is currently using *multiple* form items: one per attribute.

#1, the code part, has to be fixed by the UC developers, or by an additional module. I don't know anything of UC's architecture, so I don't know if this is possible.
The admin UI part *could* also be solved using Hierarchical Select, thanks to its ability to create new items. I wouldn't recommend this though, because it doesn't allow you to create "multiple parents" items. I.e. size X should be available for type A *and* type B. Using Hierarchical Select to create size X for both types would result in two different sizes, at least internally. This depends on UC though.

#2 must also be supported by UC. Hierarchical Select, is a *form element* and will therefore result in *one* form item that contains everything. This will require changes in the #validate and #submit callbacks.

This is pretty much all information that's needed to get support for Hierarchical Select in UC. #1 will always be necessary if you want hierarchical attributes, #2 is a necessity for Hierarchical Select, but might not be an issue in case a custom system is used.

Some important notes before you decide to write a custom system:
- Hierarchical Select degrades gracefully: JS enabled vs. JS disabled and keeps functioning in the same way if JS is disabled!
- Hierarchical Select is *scalable*
- Hierarchical Select already supports: taxonomy, content_taxonomy, the exposed filters in views of the both of these, taxonomy_subscriptions, a university is using it to browse a tree-like web service, a client is using it to dynamically mix multiple vocabularies
- triggers JS events to allow for advanced interactions (e.g. dynamic updates of other parts of the page, e.g. image, price, …)
- has been tested in all major browsers: IE 6/7, Firefox 2/3, Safari 2/3

What I'm trying to say: Hiearchical Select is designed to support *every* scenario and hopes to become the single, standard widget to do this. So it doesn't make much sense to duplicate this project!

Phew. This is the longest forum post in years for me! I hope you liked what you read Smiling

Posts: 88
Joined: 01/02/2008
Bug Finder

i'm interested to see where this leads... tracking.

Posts: 4767
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hey Wim, I don't have time right now to give a thorough read and response, but this is more Lyle's realm anyways. Eye-wink I still wanted to give a quick reply.

Believe it or not, Lyle and I were just playing around with the hierarchical select demo yesterday! I was blown away. I'll leave it up to him to do think about integration w/ attributes/options. This could certainly be helpful for other parts of the cart, like categorizing products in a hierarchical catalog taxonomy vocab.

I'll bookmark this post and revisit it if I can. Thanks so much for stopping by!

Posts: 5
Joined: 06/26/2008

Ryan wrote:
Hey Wim, I don't have time right now to give a thorough read and response, but this is more Lyle's realm anyways. Eye-wink I still wanted to give a quick reply.

Believe it or not, Lyle and I were just playing around with the hierarchical select demo yesterday! I was blown away. I'll leave it up to him to do think about integration w/ attributes/options. This could certainly be helpful for other parts of the cart, like categorizing products in a hierarchical catalog taxonomy vocab.

I'll bookmark this post and revisit it if I can. Thanks so much for stopping by!


Hehe Smiling I'll await Lyle's reply then!

By the way, using HS for taxonomy will only require a simple change in your form definition (change #type and pass the configure the HS settings).

Posts: 2109
Joined: 08/07/2007
AdministratoreLiTe!

Yeah, it's pretty funny that you would bring this up the day after we found your demo. I've been impressed by the hierarchical select field ever since I first learned about it (however long ago that was). I think a lot of parts of Ubercart would benefit from using it, including attribute selection.

The questions on my mind right now are what to do with the current attribute module. Like you said, it would have to have major changes to be able to incorporate hierarchical selects. This is due to the fact that I assumed a lack of hierarchy in attributes when I wrote the module. It's a lot easier not to worry about them when you don't need them. It looks to me that we can use hierarchical selects and still keep the functionality of completely independent attributes. I just want to make sure that it's still relatively easy.

However this ends up happening, I don't expect anything to be done until everyone's ported to Drupal 6. I saw where you plan on doing that after 5.x-3.0 is done. Ubercart should be usable on D6 by then, so we've got plenty of time to discuss and think about it.

Posts: 5
Joined: 06/26/2008

Lyle wrote:
However this ends up happening, I don't expect anything to be done until everyone's ported to Drupal 6. I saw where you plan on doing that after 5.x-3.0 is done. Ubercart should be usable on D6 by then, so we've got plenty of time to discuss and think about it.

Excellent. I'll revisit this when I finish the D6 port, then.

If you need my feedback here, you can find me in #drupal a lot, so you just ping me there Smiling That said, I doubt you really need any feedback from me. Like you said, all that needs to be done is storing the attributes in a hierarchical manner.

P.S.: I don't know what attributes look like internally, but if it's just id-string pairs, then you can of course just use Taxonomy for that.

Posts: 9
Joined: 06/27/2008

I was searching for something like this but ended up here, funny thing is that I did the search yesterday and found the thread on drupal that also had a link here.

I'm not so certain that #1 by Wim has to be code changes to UC's attribute module. The way I see it is that the uc_attributes table and the uc_attributes_options table should not be touched as these 2 tables just aggregate what options should be under a certain attributes. For example color can have, blue, green, yellow, and red, it doesn't mean that these are assigned to a product.

The attribute/options to product assignment are done in 2 different tables. uc_products_attributes and uc_product_options. again I don't see why these tables need to be change as this allows the system to know that this product get a color, size, or what have you and that under color we have blue and red of one particular product but yellow and green of various sizes for another. This only describes what is allowed for that product in terms on attributes and options

what needs to happen is another table that describes the hierarchy. For example, product 1 and 2 has size, color, and style. Product 1 has small, med, and large for size, blue, green, and red for color, and logn and short sleves for style. product 2 has same sizes, but different colors, and no styles. if the Hierarchy is described in the uc_attributes and uc_options, then every product assigned that product would be assigned that hierarchy as well. which for this example doesn't work. So a new module has to be made that would assign the hierarchy of the attributes first, i.e. size controls color, color controls style, and that is assigned to the product, not to the overall attribute. From there you go about setting product 1 attribute 1 option 2 allows attribute 2 options 1,2,3 then go to product 1 attribute 2 option 1 allows ...

The hardest part on this would be creating the forms and setting the jquery chain and the xml to make the jquery pull the data from the db, unless you statically set the data for the selects in the javascript.

What I don't see is why this has to wait until a port to drupal 6 as I don't see why it couldn't be done now. I think that the attributes have to be assigned to the product before any hierarchy can be assigned. I believe that the hierarchy has to be assigned to the products rather then the attributes to allows the most flexibility because assigning the hierarchy to the attributes themselves makes it a global thing. If you want global assignment of attributes, set up the hierarchy on a class, then assign that class to the product as it can already be done that way. as far as I can detect, when you assign it that way it just copies over to the uc_products_attributes and uc_products_options, so I imagine when a class is assigned, some hook will need to be made to detect that so that it will also copy over the hierarchy as well.

I wish I had more time to help with coding, but I barely have time to make comments some days.

hope this helps.

Granville
granville [at] kirkhamsystems [dot] com

Posts: 9
Joined: 06/27/2008

looks like I spoke before I understood that HS is not an Ubercart module, but a Drupal module. So I guess a module could be made to setup the hierarchy, and then somehow use HS to make it all happen. I guess I got a bit confused when the link to HS above linked to Drupal's main download page and not directly to the HS module itself.

Posts: 5
Joined: 06/26/2008

graper wrote:
looks like I spoke before I understood that HS is not an Ubercart module, but a Drupal module. So I guess a module could be made to setup the hierarchy, and then somehow use HS to make it all happen. I guess I got a bit confused when the link to HS above linked to Drupal's main download page and not directly to the HS module itself.

Indeed.

That's the reason for my #1: I need hierarchically structured data before I can present it through HS. How that happens, doesn't matter to me Smiling

Posts: 3
Joined: 05/13/2008

I am hgoing to heel and back trying to have a product " pizza'
and select multiple toppings. Currently when I set the attribute i have to set just 1 default.
I try to set yes and no attributes for each topping - but I have 23 toppings and it gets to long a list. ALso it makes a mess when I have the order, because it does not list just the ones i chose YES, it lists ALL of THEM!
IS there any solution for that?

Thanks!

Posts: 18
Joined: 06/05/2008

hi folks,
some weeks ago i also wrote a forum article about my need of hirachical selection of atributes. so i played around after ryan told me it could be a good idea to take HS for drupal and icorporate it to the ubercart by just playing around with some code (i´m not a coder at all ;-()
so my question to WIM is there any chance to incorporate the HS to the ubercart 1.0 with drupal 5.8 ? i have a usecase on that and would be happy to share my ideas about the functionality with you and if i can do any work to get this contribute to work with the current version i would be happy to get a hint by you - even if you need a box of beer i would spend it Eye-wink

thanks in advance
carsten

Posts: 64
Joined: 04/01/2008

Why change all attributes?
I think it would be nice to add HS as a different kind of attribute. So standard attribute and HS attribute.
It would just need a new HS_attribute module and leave the decision of what to use to the user.

Or am I missing something? The old attribute is also something like a contrib. It just hooks into the product form and cart display.

Thanks
Mark

Posts: 8
Joined: 07/24/2008

I'm one of the many people who desperately needs this functionality. Sounds promising and I hope to see it any time soon Smiling

Posts: 2
Joined: 08/27/2008

I too need this desperately and I realized that ubercart was missing this functionality only after setting up my website. Now I am stuck as without this functionality my product selection is very messy. Sad Any updates on when can we get this?

Posts: 5
Joined: 06/26/2008

I will not be doing the work that's necessary to allow for hierarchical attributes. That's UC' developers responsibility, and seems an extremely basic one to me, but for some reason it hasn't been very needed so far by anybody.
As soon as there are hierarchical attributes, I'll write the HS implementation.

So … you'll have to get feedback from the UC developers and push them, rather than me.

Any words from an UC dev? Smiling

Posts: 2109
Joined: 08/07/2007
AdministratoreLiTe!

Still working on getting Ubercart ready for Drupal 6. I imagine things like hierarchical attributes will be done after that.

Of course, that shouldn't stop someone else from taking on the project.