
I'm manually using the configs and classes for a migration built on migrate_plus from Commerce 1.x > 2.x
My product migrations were failing because the reference to the new product variation wasn't mapping correctly. I determined that this is likely caused by hardcoding product_id:product_id in the migration config which will attempt to set the product id to be the same as 1.x's id.
I see two ways to solve this:
1) remove id mappings and let migrate do it's thing
2) update the product variation migration to map `variation_id: product_id` instead of `product_id: product_id1`
Comment | File | Size | Author |
---|---|---|---|
#23 | interdiff.txt | 302 bytes | quietone |
#23 | 2899426-23.patch | 6.85 KB | quietone |
#21 | interdiff.txt | 1.08 KB | quietone |
#21 | 2899426-21.patch | 6.86 KB | quietone |
#15 | interdiff.txt | 1.11 KB | quietone |
Comments
Comment #2
andyg5000Comment #4
andyg5000Let's try option 2 which is actually what I ended up using on my migration.
Comment #5
heddnIs this the same thing as the failing test I found over in #2899321: Refactor Commerce Product and ProfileBilling tests? In there, I suggested we use migration_lookup and transform to the actual id. If this is better, fine. But I'd still like to see a failing test too, which we have over there.
Comment #6
quietone CreditAttribution: quietone at Acro Commerce commented@andyg5000, glad you found something that worked for you.
I agree with heddn that a migration_lookup is desirable. Though I don't see the path yet on that because of the back referencing going on. Somewhere else mglaman suggested that a post event subscriber was needed to handle this problem, similar to the existing one for orders. After mulling it over, I see that as the way to do this. I have made a initial patch with that in mind and added comments in the migrations to caution that the product id in the product variation is not correct after running the product variation migration. It is a start.
Comment #8
quietone CreditAttribution: quietone at Acro Commerce commentedOnly run the post event MigrateProduct when the migration id is 'd7_product_displa'.
Comment #9
quietone CreditAttribution: quietone at Acro Commerce commentedNow, add in the changes in patch #4. changing the destination from product_id to variation_id in the product variation migration (d7_product.yml). There is now a variation_id that we can use with migration_lookup in the product migration (d7_product_display.yml).
Comment #11
quietone CreditAttribution: quietone at Acro Commerce commentedModify the test since all product_ids in the product variation migration are now NULL, reflecting that the product has not yet been migrated.
Comment #12
heddnUnfortunately, needs a re-roll.
Nit: missing new-line.
This was recently re-named.
So, if I get this right, it is NULL in the variation test, but now its accurate in the ProductTest? Great. That's what I'd expect.
Comment #13
quietone CreditAttribution: quietone at Acro Commerce commentedRerolled. 1 and 2 fixed.
Is there something to do for #3. It looks like you answered your own question.
Comment #15
quietone CreditAttribution: quietone at Acro Commerce commentedMissed renaming some migrations.
Comment #16
quietone CreditAttribution: quietone at Acro Commerce commentedChanging component since this is really only for Drupal Commerce 1 sources.
Comment #17
quietone CreditAttribution: quietone at Acro Commerce commentedAnd doesn't need a reroll.
Comment #18
quietone CreditAttribution: quietone at Acro Commerce commentedAnd this is blocker for #2814003: Remove commerce_migrate_commerce_reference and refactor references to use default migration process and #2899153: Cannot add variation to cart, due to failed store detection
Comment #19
mglamanThoughts:
* We should replicate the AddToCartForm submit method in a test to help verify products can be added to a cart.
* Saving a Product will automatically populate it's variations back references, see https://github.com/mglaman/commerce/blob/8.x-2.x/modules/product/src/Ent... line 314. That should simplify the event subscriber
Comment #20
heddnSeems like some work to me. Back to NW for #19.
Comment #21
quietone CreditAttribution: quietone at Acro Commerce commented#19.1 I think that is out of scope. All for testing that functionality, but lets do that in #2899153: Cannot add variation to cart, due to failed store detection. Worst case is the we keep adding modules and tests here. I think we have fixed the problem in the IS.
#19.2 The event subscriber has been simplified.
Comment #22
mglamanThat's fine, we can add the test elsewhere.
Fix looks good to me, event subscriber simplified and tests pass!
Comment #23
quietone CreditAttribution: quietone at Acro Commerce commentedOh. This hasn't been committed!
Went to commit it and there is an extra line in the patch in #21. Let's fix that first
Comment #25
quietone CreditAttribution: quietone at Acro Commerce commentedNow set as fixed.
In hindsight, hope no one minds. After all it is a blocker and the whitespace was not a code change.