The following Tokens are currently defined in commerce/modules/product/commerce_product.tokens.inc:
[product:product-id]
[product:sku]
[product:type] (the human readable type name)
[product:title]
[product:edit-url] (the absolute URL to the edit form defined by Product UI... hmm, I'm guessing this should be moved to the UI module!)
[product:created] (this is a date Token that can be extended, i.e. [product:created:short]... defaults to medium)
This list does not include Tokens for the changed date or for the product creator, two default values of the product object. Furthermore, as mentioned above, the edit-url Token should be moved to a Token include file for the Product UI module and have an additional view-url Token added. This will go to the currently non-existent View page once #733044: Add build modes for products gains traction.
Are there any other Tokens that need to be added here? Does anyone know what we'll need to do for Tokens defined by Fields?
Patches welcome. : )
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | commerce-733356.patch | 4.52 KB | bendiy |
Comments
Comment #1
rszrama commentedAhh, and any additional Tokens will need to have Test coverage; see the testCommerceProductTokens() function in commerce_product.test.
Comment #2
bendiy commentedAttached is a patch that can serve as a first pass as this issue. I'm not sure if $product_ui should stay as $product in some places.
Comment #3
bendiy commentedHere's a list of possible additional tokens. Some will probably be defined by additional fields:
Comment #4
dave reidWhy not rather make a [product:creator] chained token that's a 'user' token type? That way you can have [product:creator:uid] automatically.
Powered by Dreditor.
Comment #5
pcambraComment #6
rszrama commentedComment #7
rszrama commentedOh, and agreed with Dave above. We should use the chained Token - see this commit filling out missing order tokens as an example:
https://github.com/rszrama/drupalcommerce/commit/9c00eedb151928710fa98d8...
Comment #8
pcambraI think that only the product author was missing.
https://github.com/pcambra/drupalcommerce/commit/8372ea44fb98473d19c376c...
Comment #9
rszrama commentedExcellent; committed, though I did change it to "Creator" in conjunction with the schema and entity property definition.
Comment #12
kenorb commented