Overriding product variation titles

Created on 26 January 2017, about 8 years ago
Updated 20 September 2024, 7 months ago

I've been trying to figure out the best way to hook in and replace the title of my variations in code when they're saved. What I'd like to do is have it generate an automatic title, but change something about that title from another module in code automatically.

The problem is that we have some "N/A" attribute values, and the auto titles are ugly because they have sometimes repeated "N/A, N/A" values in their titles, and our client doesn't want those there (and I can understand why). Since their products are so varied that we can't really get around some attributes not applying to some products, and since attribute fields require a value, the N/A value was the way around that. it seems the only real way around the title issue is to override the variation titles and remove those N/A values.

I've tried ProductEvents::PRODUCT_VARIATION_INSERT and ProductEvents::PRODUCT_VARIATION_UPDATE but trying to set the title there simply has no effect, it gets overridden after that again if I have automatic titles enabled.

Is there a later hook I should use, or another recommended way that I could achieve the desired effect of modifying the auto-generated variation title (automatically, every time a variation is saved)?

πŸ’¬ Support request
Status

Needs review

Version

2.0

Component

Developer experience

Created by

πŸ‡ΊπŸ‡ΈUnited States bmcclure West Virginia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !338Overriding product variation titles β†’ (Open) created by scottsawyer
  • Pipeline finished with Failed
    7 months ago
    Total: 451s
    #289075
  • Pipeline finished with Failed
    6 months ago
    Total: 436s
    #294673
  • Pipeline finished with Failed
    6 months ago
    Total: 540s
    #300887
  • Pipeline finished with Failed
    6 months ago
    Total: 166s
    #300935
  • Pipeline finished with Failed
    6 months ago
    Total: 470s
    #300973
  • Pipeline finished with Failed
    6 months ago
    Total: 754s
    #304012
  • Pipeline finished with Success
    6 months ago
    Total: 400s
    #304225
  • Pipeline finished with Success
    4 months ago
    Total: 188s
    #369745
  • Pipeline finished with Success
    4 months ago
    Total: 828s
    #373775
Production build 0.71.5 2024