7 replies [Last post]
regx@drupal.org's picture
Offline
Joined: 10/30/2007
Juice: 98
Was this information Helpful?

I just created a module to copy the class, attributes and options from one node to nodes of another class/type.

While working on this I realized that updating class options/attributes does not update all of the items of the class/type. Is this by design, or is my ubercart installation that dated?

When I tried to update ubercart it blew off all of my product images. I was able to get the thumbnails back but the images were not re-scaling properly so I just restored from backup and will look into this further when I have more time.

Currently my module is very simple, but could easily be enhanced to allow copying attributes to node selections, have the class/type copying optional as well as an option to update nodes when updating the class. I haven't committed it cvs yet. Basically I just wanted to put the feelers out to see if this functionality would be useful to others, and to make sure I am not duplicating functionality in the latest ubercart version before committing.

regx@drupal.org's picture
Offline
Joined: 10/30/2007
Juice: 98
Here is the current module

This is the module in the current state.
Just goto admin/content/uc_copy_attributes, enter a node ID and select the node type to copy the attributes to.
Since the nodes will take on the type of the source node it is recommended that you edit a node in the class you want to copy the attributes to. Hopefully that makes sense. If the source node is of type product and you select t-shirt as the target class then all of your t-shirts would then be products. I actually needed this and it was the original reason for creating the module. It wasn't till I made all of the product nodes a new type that I noticed that the class attributes where associated with the individual nodes and not the class. So, just edit one of your t-shirt items and update the attributes and options the way you them to be for all of your t-shirt items. Then goto admin/content/uc_copy_attributes and enter the nid for the t-shirt you edited and select t-shirt as the target type. Bingo now all your t-shirt items have the new attributes/options.

AttachmentSize
uc_copy_attributes.tar.gz 2.74 KB
seedseller's picture
Offline
Joined: 11/27/2007
Juice: 141
Re: Here is the current module

I'm trying this out. With each product node storing attributes locally, it is difficult to even do things like make a price change to all products using a particular attribute. Please do continue development.

One idea for further exploration--would it be possible to change individual attributes. Suppose one finds a spelling error or want to make a price change on the yellow t-shirt only. Currently, this is done by disabling the old attribute and enabling the new version product by product. Could you expand this module to do global changes on individual attribute changes?

Now that would be awesome!

regx@drupal.org's picture
Offline
Joined: 10/30/2007
Juice: 98
Sure

Well, for spelling errors I would imagine you would want to update the attributes for all the items.
As long as the items are in a separate class, then this module would work great for that!

I intend to update this module to allow individual item selection. Which would allow you to apply the attributes, options and class from one node to just the selected nodes. I am debating where to put this, but probably as a hook into edit content since that form already has a filter and node selection.

Other than that my only plans are to add the option to update items in a class when the class is edited.
Basically, this would be a form alter hook for the class attributes/option forms that would update all items of that class/type to match the class. I was surprised that it didn't work like this already. Since it doesn't I imagine there is a strong use case for having it not do that so I will make it optional.

regx@drupal.org's picture
Offline
Joined: 10/30/2007
Juice: 98
I think I misunderstood your suggestion.

After re-reading your post, I think what you are asking for is to be able to change an attribute so that the edit applies to all items with that attribute. Is that correct?

Yes, that could be done fairly easy.
Would you need the ability to update the options as well.

Edit item attribute form
[] apply edit to all items using this attribute?

Edit options form
[] apply edit to all items using these options?

Honestly I think that attributes should not be a global thing unless applied to a class. The reason for making a class is so that all the attributes/options get created when you create a new item of that class.
So updating the class options should be global. If you have one item that needs different options just put it in a different class, or just make it a product and set the attributes manually. This makes it easier to track attributes, put all items in a class on sale, etc.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: I think I misunderstood your suggestion.

Interesting thoughts. I do like the idea of edits to a class's attributes/options being pushed out to all products of that class. This late in the game it won't make it into 1.0, but this feature could start out as a contrib module that hooks into that form w/ hook_form_alter(). This would make it easier to get some testing in so we could roll it into the next version. Cool

seedseller's picture
Offline
Joined: 11/27/2007
Juice: 141
Re: Re: I think I misunderstood your suggestion.

To my mind a global option allows for mundane things like changing a name or spelling of an option. More importantly, it would provide an easy method for globally changing the price of an option.

For example, I recently had a need to change the attribute pricing structure. Changed it, then had to go through the store changing the attributes for each product. It took several hours to redo 400 products one-by-one.

regx@drupal.org's picture
Offline
Joined: 10/30/2007
Juice: 98
Me too

So long as products are arranged in classes, then this module works as a rough hack which was sufficient for my immediate needs.

Another option that wouldn't be too hard is to add an option when editing attributes, give the option to update all attributes for items in the same class that have the same attributes and as well as an option for the options.

I can see a use case where a user has a bunch of t-shirt class items, and has manually updated the prices on a few and wants only the items that have the same attributes/options as the item being edited (before the edit) to be updated with the new values. With the class solution, the T-shirts would have to be in separate t-shirt classes.