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.
Once a Product type is created, I cannot change Variation type in Product type. Is this a feature?
This is useful because I want to use entity_clone and create multiple similar Product types and change the variation type after the clone.
Comment | File | Size | Author |
---|---|---|---|
#9 | 3014686-9.patch | 3.53 KB | bojanz |
| |||
#6 | commerce-3014686-change_variation_type-6.patch | 3.32 KB | czigor |
|
Comments
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedIt is a feature, because changing this after creating products would cause breakage.
However, the check is too strict. We can allow changing the variation type as long as you don't have any product entities created.
That would satisfy the clone use case.
Comment #3
petergus CreditAttribution: petergus commentedok, thanks for clarifying. Rather than waiting for patch or try to code under time pressure, as a workaround I have been using Field tools to clone all fields and displays over.
Could you tell me where I would have to change the referenced variation in the database?
Comment #4
bojanz CreditAttribution: bojanz at Centarro commentedThis is config, it's all serialized, there's no db column to change.
Comment #5
petergus CreditAttribution: petergus commentedAh that's why I couldn't find it :D Guess I will continue with my field-tools in the meantime since I wouldn't know where to start with contributing a patch.
Comment #6
czigor CreditAttribution: czigor at Centarro commentedComment #7
petergus CreditAttribution: petergus commentedWorks great!
Comment #8
bojanz CreditAttribution: bojanz at Centarro commentedThe fix looks good. Tests need a bit of cleanup:
This line is too long and hard to read. Let's assign $variation_type_field on the line above, then use that in the assert:
Should use $this->createEntity() for consistency.
Comment #9
bojanz CreditAttribution: bojanz at Centarro commentedEDIT:
Missed the SKU field, no such thing on a product. Can be fixed on commit.
Comment #11
bojanz CreditAttribution: bojanz at Centarro commentedDone. Thanks, Andras!