Having a Dress product type, how can I achieve this for SKU: DR-0001, DR-0002 for all entered dresses automatically as they are entered?
The number shall increase based on the number of nodes = actual products entered

Previously, with Auto NodeTiltle, and Token module, I could format this output using simple php code.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rbayliss’s picture

Category: feature » support
Status: Active » Fixed

This should be possible with a bit of custom code. You'll need a hook_token_info() and a hook_tokens() to provide a token that determines the product's id in the sequence (the 5th t-shirt, etc). I suspect this will be pretty similar to what you did for nodes previously.

Salman_Rahma’s picture

Category: support » feature
Status: Fixed » Active

Thank you for your suggestion. The PHP code I used before was only for formatting the output and I had copied from some site. unfortunately I am not a coder and I think this would be a nice feature to be added out of the box for the module.

kmolkens’s picture

I have a similar request.
It would be interesting to have the possibility to add a Pattern for the SKU based on custom PHP code.
In Drupal6/Ubercart, I used Product Power Tools allowing a field for entering PHP code.
This is very useful to calculate a SKU used for barcode scanning.
The code calculates a sku conform to EAN-8 or EAN-13 or ... barcode numbers (including checksum,...).

kevinsiji’s picture

Version: 7.x-1.0-beta4 » 7.x-1.1
Status: Active » Needs review
FileSize
4.51 KB

Here is a patch.

This will also provide a facility to decide the starting number.
You can provide the static part of the sku in the token pattern (a real token is not necessary) and the starting number in the textbox provided under the 'Advanced' fieldset.

Criticize this patch, so that I will learn my mistakes.

SocialNicheGuru’s picture

Issue summary: View changes

I would like an option to add this to the end of my tokenized autosku value.