Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a custom field on my Product Type for brand names of the products. Im using this custom field brand name as part of my AutoSKU pattern like [commerce-product:field-brand]-[commerce-product:product-id]. Which works pretty fine.
However, some of the brand names I have are pretty long and makes the SKU way too much longer then I would like it.
Is there anyway to limit the number of characters to be used in this token? Like maybe taking the first 3 or 4 characters of the brand name field as part of the pattern?
Thanks...
Comments
Comment #1
paranormals CreditAttribution: paranormals commentedCame across AutoSKU today. Thanks for the nice simple module. I was looking for the same feature as hgurol. A way to truncate fields to keep my SKU's shorter.
Comment #2
rbayliss CreditAttribution: rbayliss commentedWe're dependent on token support here. There's no way I know of to shorten a token value, although you can always create your own version of the token if you've got some coding chops (http://rbayliss.net/story/tokens-drupal-7).
Comment #3
hgurol CreditAttribution: hgurol commentedWell, creating my own token is not something I can do myself.
If you can think of an easier workaround, doesn't matter how dirty it is, I would really appreciate that.
Thanks...
@paranormals
Maybe you have already came up with a workaround?
Comment #4
paranormals CreditAttribution: paranormals commented@hgurol - I did not come up with a work around yet. Sorry.
Comment #5
ahillio CreditAttribution: ahillio commentedWith fields of type "List (text)" we can specify key|label. I have list of colors dg|Dark Green and other lists built like that. Autosku's are being built with the label (Dark Green), but it'd be great if they could be build with the key (dg). Is this possible?
It sounds like this would depend on token being able to access the key?
Comment #6
ahillio CreditAttribution: ahillio commentedThis can be done!
@hgurol ...4 months later, if you're still working on this... you can abbreviate your brand names this way:
Wonder if title of this post should be "abbreviated sku" or the likes and instead of "custom pattern". Would it be improper for me to change it? Not certain about the etiquette here...