11 replies [Last post]
avolve's picture
Offline
Joined: 09/14/2007
Juice: 47

On a recent project, i was able to auto generate many things via hooking into the token module. I noted that it is required for ubercart - is there a way it can be hooked into to auto-generate an SKU. This could be as simple as a string of letters followed by the node-id (the only issue would be that non-product nodes would not provide for sequential numbering - product id perhaps?)

I am not sure how relevant/widespread its application would be. For the project i am working through, it would be as it is for an artist's work.

I was also thinking in terms of having different SKUs for attributes. For example, what i am trying to achieve is to have an original artwork and prints. There would only be one original (i am working though inventory control as well - stuck on both for now) and a select number of prints, if any. In this case, the prints SKU could have a -p added, for example, at the end.

Given that this would be the same for each product (artwork) i think i should be able to create a class to apply automatically for the attributes as well - this is for another thread, however - as are my current fumbling's with inventory control Eye-wink

psynaptic's picture
Offline
Early adopter... addicted to alphas.Not KulvikTheminator
Joined: 08/28/2007
Juice: 731
Re: auto generate SKU (using token module)?

This is something that I am interested in. It would save the effort of store admins from having to check which is the next available model number.

I built an auto-generate model number contribution for oscommerce that queries the database for the products_id and products_image or products_name fields then constructs and inserts a configurable model number like so:

XXX-YYY-001

Where:

XXX = User defined letters (usually an acronym of the store name (such as UBT for Ubercart)).
YYY = First three letters from the products_image or products_name fields (usually gives a good idea of the actual item).
001 = The products_id ensuring each model number is unique.

The problem with using this script with Ubercart is that SKU is required to add a product.

I have been thinking a little about this and (despite not knowing much about token module) I believe your idea of using token module could be the right one. There would need to be a settings page where the format would be defined - probably something like the way pathauto handles it's url formats.

Ideally the value="" of the SKU field would be prepopulated with the auto-generated model number allowing for overriding when necessary.

Sorry I haven't got more than this to offer. I can code for oscommerce but Drupal/Ubercart is still mostly a mystery to me (have bought the pro drupal development book and am working through it though so it shouldn't be long before I can contribute more)

oslinux's picture
Offline
Joined: 09/06/2007
Juice: 461
Re: Re: auto generate SKU (using token module)?

what about hiding the field with cck permissions and then afterwards change it be checking the db which products still have sku = lame-needstobechanged ...

psynaptic's picture
Offline
Early adopter... addicted to alphas.Not KulvikTheminator
Joined: 08/28/2007
Juice: 731
Re: Re: Re: auto generate SKU (using token module)?

I've not thought about this. Have you tried anything similar in the past that worked in this way? Is CCK permissions a module?

amitaibu@drupal.org's picture
Offline
Bug Finder
Joined: 09/08/2007
Juice: 239
Re: Re: Re: Re: auto generate SKU (using token module)?

Problem with using Token, is that the SKU should be prepopulated with a node id that still doesn't exist (as the product was not yet submitted).

I'm thinking maybe there should be a configuration in UC saying "Make SKU same as Node id"

psynaptic's picture
Offline
Early adopter... addicted to alphas.Not KulvikTheminator
Joined: 08/28/2007
Juice: 731
Re: Re: Re: Re: Re: auto generate SKU (using token module)?

Yes, just as long as we can get past the submit product part we could do what we like with the database. I have been adding my products as SKU = "a" and then later will format the model numbers using a script. Would be nice to have an option that made node id populate the SKU field on the submission form.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
I'm thinking maybe there

I'm thinking maybe there should be a configuration in UC saying "Make SKU same as Node id"

I'm confused, why would you want the SKU to be the same as the node id? Since nids are usually numbered incrementally, if you create content other than a product, your SKUs will go out of order once you start switching back and forth.

I do like the idea of having the SKU field pre-populate, but I think it should be based off an earlier SKU value. Maybe there can be a token pattern assigned for such a function. I would also be able to use different SKU patterns for different vocabs or product types. Downloadable content gets "D-###" and Shippable product gets "Prod-##-alpha" or whatever the need is.

I'm making things more complicated, aren't I? Eye-wink I'm good at that.

--
Help directly fund development: Donate via PayPal!

amitaibu@drupal.org's picture
Offline
Bug Finder
Joined: 09/08/2007
Juice: 239
Re: I'm thinking maybe there

Well, in fact I'm not using the SKU at all. My product reference is the NID. Every new NID is a new product. Having to enter manually an SKU for me (thus I assume maybe others) is not necessary.

natcolley's picture
Offline
Joined: 01/13/2008
Juice: 48
Re: Re: I'm thinking maybe there

I'm still interested in an auto generated sku. As for using the node id instead, how exactly did you accomplish this and what about the downsides - e.g., a product with many attributes can no longer have those attributes distinguished or inventoried separately by their own unique sku?

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: auto generate SKU (using token module)?

You can check out the auto_sku module and see if it helps. Feedback welcome.
http://www.ubercart.org/contrib/4307

Biodiesel * (ubercart + drupal) = Sundays Energy

borgo's picture
Offline
Joined: 03/14/2008
Juice: 31
settings location

Thanks a lot webmasterkai.

For those who, as me, were looking for config panel its collapsed under admin/store/settings/products/edit.

jamessammon's picture
Offline
Joined: 10/30/2009
Juice: 2
Re: auto generate SKU (using token module)?

You must first create attributes and attribute values in the store's default language, followed by any supported languages. If there are no defining attributes for the product, the SKU generation will create a single SKU by copying information from that product.

Bike Parts