Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Just like we're using Commerce AutoSKU for sku generation, we can use Automatic Entity Label to generate product titles.
We just need to remove the custom code, and configure auto_entitylabel if present (in the update function).
auto_entitylabel will provide many gains, such as handling multiple languages properly
Comment | File | Size | Author |
---|---|---|---|
#1 | auto_entitylabel_producttitle.jpg | 46.82 KB | ayalas |
Comments
Comment #1
ayalas CreditAttribution: ayalas commentedDoes this mean the title auto generation custom code would be removed, yet this module's "auto generate title" checkbox would remain and, following #1787838: Support Automatic Entity Label module, checking it would configure auto_entitylabel module to copy the title from the parent node to the variation? If so, that's great.
I'd love to upload a patch, yet I am having trouble configuring auto_entitylabel to work this way, even through its own UI. This is the current setting I defined:
The result is that the node title is copied only once, upon the creation of a product. New translations are not copied, nor do original-language node title updates.
With the auto-generation custom code (which is now disabled) the result was much better (of course, only after #1545896: Add Entity Translation integration) - translations got applied, yet node title updates didn't.
Comment #2
nithinkolekar CreditAttribution: nithinkolekar commentedwhether title is being generated using 'Automatic Entity Label' or Inline Entity Form's autogeneration method, it would only generate when title field is left blank providing some help text like 'leave this field bank for auto title generation' or 'enter your own title'.
Comment #3
zkrebs CreditAttribution: zkrebs commented#1 does not work for me, is there a reason this token would not work? I have token / entity modules installed/enabled.
Comment #4
cravecode CreditAttribution: cravecode commentedThis is a fantastic solution and worked great in my testing.
I originally created the "Make Commerce Product "autogenerate_title" themable" issue but stumbled on this one and it's obviously a better route.
FYI: I'm using the
7.x-1.x-dev
version of the auto_entitylabel module.Comment #5
T.Mardi CreditAttribution: T.Mardi commentedHey all, I'm needing this feature as %AutoEntityLabel% keeps appearing in various places when Auto Entity Label is used with Commerce Backoffice.
What portion of the IEF code needs to be removed and where does the token in #1 come from?
Comment #6
B-Prod CreditAttribution: B-Prod commentedActually I cannot figure how to get the parent node title using Auto Entity Label... The tokens available in the product label form are only related to *product* entities, not nodes.
That's why I don't think removing the IEF auto title feature is a good idea, unless this case is handled properly by AEL.
@ayalas: In your example, it seems you are using a Reference field in your product that link to the parent node. Why not, but in a normal case, we only have a *Product reference* field on the parent node. So we need to have access to the tokens of this parent in AEL, which is not currently the case.
Comment #7
B-Prod CreditAttribution: B-Prod commentedOK, I found a solution about the parent reference issue: Entityreference Backreference. This module provides token for reverse entity references.
Tested with a node that references products through *product_reference* field : Auto Entity Label generates the expected title.
FYI: this works also with Commerce Auto SKU.
Comment #8
jerry CreditAttribution: jerry commentedUsing the
[commerce-product:field-product-node-eb:0:title]
token provided by the Entityreference Backreference module also worked fine for me when applied to the AEL configuration for a product variation linked with the usual product reference field. I disabled the "Auto generate the product title" option in IEF for the reference field. Newly-added variations don't display a value in the IEF widget for that token until the display node is saved, but that's a minor issue (for me).It's still the case that an update to the display node title isn't reflected in the linked variation titles until the latter are re-saved.