Thank you, tcindie for the great coding. Your implementation works perfect and very useful and really powerful. Could you make it even more powerful?
Let say we have one print in different sizes. We created class of the product with attributes/ options for each size of the print. Is it possible to add auto SKU number generation for the options / attributes? Your great tool already auto generates SKU number.
For example we got main SKU number for the product 09093010 and
for option "print on paper 8x10"" will could have SKU = 09093010_print_on_paper_10x12 or at least by adding number of the option in the list: 09093010_1
for option "print on paper 12x16"" will have SKU = 09093010_print_on_paper_12x16 or at least by adding number of the option in the list: 09093010_2
Could you help in this matter?
I am attaching image with options. Thank you in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

techypaul’s picture

Hi,

This is something I really want.

I would look at it differently and allow our own methods - for example, I don't want to have text or _ type chars as we use a till in-store, just grabbing another 6 digit number would be ideal for me, or maybe a 4 digit number for the normal item followed by a two digit number for the attribute to make a single number, whatever, but please allow for some configuration.

P.

willvincent’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not sure if this is doable, given the way that attributes are handled by ubercart. It is something I looked at before and will have to look at again to see whether it is an option.

techypaul’s picture

I wonder if you could use a new table "SKU" and when it saves the attribute or main node, it just grabs the next available row and overrides whatever the SKU was? This wouldn't allow for much customisation but it certainly would be a unique number.

willvincent’s picture

The problem is that once you start working with products that have more than a single attribute that method no longer works.

techypaul’s picture

Hey,

Sorry for the silly question, but why is that? Why does one attribute work ok, but two not?

Thanks,
Paul.

willvincent’s picture

Status: Postponed (maintainer needs more info) » Postponed

Well, I suppose it might, but lets say you have a base product with a sku tshirt, and it's available in the colors: red, black, and orange. and sizes: S, M, L, XL, XXL

You would wind up with something like this for your skus using this method:

Small Red: tshirt-1
Small Black: tshirt-2
Small Orange: tshirt-3
Medium Red: tshirt-4
Medium Black: tshirt-5
Medium Orange: thsirt-6
etc..

perhaps a better option would be to specify what token to use for each attribute option (like the attributes name, etc)

so then you'd have tshirt-red-s, tshirt-red-m, etc..

I don't have the time to really dig into this at the moment, because the attribute/option system is a little convoluted, especially when people use a LOT of attributes.

Since attributes and their options aren't set up until a product is created, I don't know off hand the best way to handle this.. it seems like it might be better suited to an addon for the attribute module. Although that certainly would still fit with the power tools module name.. Hmm... let me think on this a while, I think I know where to go with it, but I've got several other things to finish up before I can dig into it.

techypaul’s picture

Hi,

Thanks for that - I was thinking differently, I was thinking more like:

Small Red:000191
Small Black: 000192
Small Orange: 000193
Medium Red: 000194
Medium Black: 000195
Medium Orange: 000196

Personally, I don't need it to be in any sort of order (barcodes for example, arent) and Small Red doesn't have to be the next item along to Small Black so if we take this example and then go off add another 500 items and then add a new colours to this item we get;

Small Red:000191
Small Black: 000192
Small Orange: 000193
Small White: 000501
Medium Red: 000194
Medium Black: 000195
Medium Orange: 000196
Medium White: 000502

Thats what I meant by using a SKU table to store the 6 digits or whatever. I don't really know how other people use their SKUs, but if its like me and just need a unique SKU per item (attributes included) then a simple unique number will do. Your point of using tokens is a good one though - no good for me as I need the SKU to be 100% numbers so I can type them into a till at my shop.

Thanks,
Paul.

willvincent’s picture

Right, it should be an option whether to use an incremental number or token replacements..

techypaul’s picture

I think so.

Been adding a lot of items today and saw a potential problem that would need to be considered. When you add or change the attribute options, the SKUs are all reset - this would cause a problem with the method I am thinking about, unless you can stop it from automatically updating the SKU and just add any in as required (e.g. the new ones).

P.

jessehs’s picture

FileSize
15.29 KB

I'm working on a site where there's a "color" attribute with 29 different options. I'm looking for the ability to add a code on the end of the main SKU to specify colors. Seems to me, to get this kind of functionality (and I don't have any idea how to do it on the backend), we'd want an additional field in the option creation form. See the attached sketch-up. Each additional Attribute could add on to the SKU in any way, ordered based on the way the attributes are ordered in the product.

So for the previous T-shirt example:

Small Red: tshirt-sm-rd
Small Black: tshirt-sm-bk
Small Orange: tshirt-sm-or
Medium Red: tshirt-md-rd
Medium Black: tshirt-md-bk
Medium Orange: thsirt-md-or

or the base T-shirt SKU (001) could added to with attribute numbers:

Small Red: 001101
Small Black: 001102
Small Orange: 001103
Medium Red: 001201
Medium Black: 001202
Medium Orange: 001203

where 001 means t-shirt, and is the product SKU
and 1 means Small and 2 means Medium
and 01 means Red
02 means Black
03 means Orange

techypaul’s picture

Thats a really good way of doing it. For now, I have been manually entering the SKUs, using a different full SKU for each item, but actually it makes sense to keep the attributes as sub-skus.

By setting it in there, I guess it means that I could add/remove attributes to the item, jiggle them around or whatever and still keep the same sku/sub-sku combo which is great.

This will be a really cool and nice way of doing it and not having to worry about SKUs changing is a definite bonus :)

techypaul’s picture

Hi,

Just wanted to let you know I have been basically doing this manually for a couple of weeks and its working well. I create a 4 digit SKU with two 00 at the end (e.g. 123400). This is my 6 digit number for using in store.

I then added a 2 digit number to the end of the options (e.g.. "Large (04)", "XL (05)" etc. When I create the attribute I just took the main SKU and replaced the last 2 00 with the options (e.g. Large would be 123404). It works really well like that for me. Because I put it in the name field I always make sure I choose the right numbers and I guess when you (if) complete it, I will just make sure the field you supply is made to be the same as what I have manually done and then remove the (04) type bit from the name.

Just wanted to prove the concept, but I think its very useful.

Thanks,
Paul.

patchak’s picture

Hey there, has there been any movement on this issue? We really need automated SKU's as well to handle stock for all possible product combinations on a big site. Is there any code we could use to jumpstart this feature??

Thanks,
Patchak

zkrebs’s picture

Subscribing. Intensely needed.

I ended up using a custom query to download the product options table, and using some excel formulas, creating the skus I needed, and then reuploaded my information to uc_product_adjustments.

Definitely not ideal, but then again, if you're a business without SKU's for your products, the issue is deeper than just importing things into Drupal or not :)

fehin’s picture

I am willing to sponsor this development. My site needs this. Since it's a marketplace I want to make is as straight forward as possible for my sellers. I don't want them to have to enter SKUs for attributes since I already have automatic SKU installed.

Please send me a message if you are willing to develop this. Thanks.

JayKayAu’s picture

This feature would be absolutely brilliant to have.

Are there any serious technical issues getting in the way, or is it possible to do this fairly easily?

Bartezz’s picture

+1 Subscribing

I've always thought that attributes sku handling was somewhat awkward in D5. Haven't worked with attributes in D6 yet but imagine it's still the same. If one adds a product which has 5 attributes with each 10 options one has to add 50 alternative attributes by hand if I'm not mistaken. If auto sku could add an attribute code to an sku it would dramatically improve the administative part. For instance when cloning products (http://drupal.org/project/uc_attribute_clone) and re-using attributes.
I'd imagine the order of the attribute code added to the sku could be added in order of the weight of the attribute.

I do see this issue is postponed, but I think it's actually still active right? Is there any progress on this? Fund raising needed?

Cheers

alobamor’s picture

+1 Subscribing

I really need the option pointed by jessehs

jday’s picture

+1 push

tons of options on our products, and would help fund a solution if someone is willing to take this up

lellobot’s picture

Based on the notes on this modules main page:

Active development is proceeding at a slow pace, due to my less frequent usage of ubercart after a career change. New fuctionality provided with a patch will likely make it into the module quicker than something just suggested as an idea.

seems like someone has to write the solution for this feature request as a patch and submit it. I don't have the skills to do this myself, but if anyone in this thread does, it'd be great if they could put in the time. Sounds like lots of us could benefit from this feature!

myregistration’s picture

Subscribing

griz’s picture

+1

mtset’s picture

+1
We would gladly pay a bounty to have the dynamic SKU feature (which generates the SKU based on attributes). We are currently developing in D7.

jerry’s picture

Subscribing.

brisath’s picture

Subscribing

guybedford’s picture

FileSize
1.74 KB

I ran this feature through a JavaScript.

Specifically, a hook to include a link on the stock page, to automatically set all items active with the default stock level given all the sku combinations.

Then also a hook on the product adjustments page to add a button to automatically generate the skus based on the underlying attribute names.

I've attached a patch that creates the javascript file in the uc_product_power_tools folder. It then needs to be added with a drupal_add_js command, which I haven't included as I actually added this in a custom module myself. Ideally, it would just be added to these pages, but it could also be added to all pages of the site with hook_init.

Perhaps someone can assist with how best to include in this case?

boiky’s picture

subscribing

willvincent’s picture

I'd just throw the drupal_add_js() call in a form_alter hook for the appropriate form_id..

boiky’s picture

subs

stuhannaford’s picture

FileSize
931 bytes

#26 In case anyone else out there is trying to get this to work, I have attached a little module as per guybedford patch which you can load and install as per usual. Works fine on my site. I have also added a class .auto_sku_options to theme the link further if you wish.

  • Adds highlighted red text link on each product attributes page to auto SKU attributes
  • Adds highlighted red text link on each product stock page to auto stock levels

I'm using Drupal 6.22, Ubercart 2.7

Hope this helps out there. Thanks to guybedford for uploading the patch!

fehin’s picture

Hello guybedford and stuhannaford, thank you for the module. Where do one set the format for the SKU? Right now mine looks like this og/w-blue. I'm not sure where og and 'w' came from. It doesn't look right to me. it will also be nice if the admin can setup the attribute combination format and have them fill in automatically and hide the adjustment page. One less page to worry about.

Also the attributes stock are not set to active as mentioned.

adamtong’s picture

I also want to know how to set the SKU...but anyway, this module is great!! thank you in advance.

remkovdz’s picture

Is an auto-generate SKU for options/attributes module also available for D7?

jiisuominen’s picture

i was searching for this also, didn't find anything so i decided for a fast-and-dirty approach and used hook_form_alter just to parse alternate sku from that adjustment-table. thought that this might be useful for someone.

i know nothing of any drupal coding standards, but here it is. works for me atleast. you will have to visit adjustments-page for this to work, but it works as is with new products. for feeds or some import function with proper adjustment handling we need some other solution. thou i'm in the need of some solution for product import as well.

drupal 7.14 and ubercart 3. i feel that this functionality should be optional in uc core.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if($form_id === "uc_product_adjustments_form"){
    foreach($form['table']['body'] as $key => $value){
      if(is_numeric($key)){
        $t=explode('</td>',$value['combo']['#markup']);
        $n=array();
        foreach($t as $tt){
          if($tt)
            $n[]=substr($tt,4);
        }
        $m=$form['table']['body'][$key]['model']['#default_value'];
        $form['table']['body'][$key]['model']['#default_value']=$m.'-'.implode($n,'-');
      }
    }
  }
}
halloffame’s picture

#26 and #30 it also appends '\' to the option's sku. I looked in to the js file and I cant find it there. Where is it defined? I wanna remove it.