I'm in the process of creating a migrate example. The first version is attached, but it's not quite ready for review, as it doesn't create product display nodes yet. I hope to do that tomorrow.
This example takes a CSV file and populates products with it. It can handle images that are either external or local.
The file handling is actually placed in the main module (it's cribbed from Feeds). I think we can probably use it more generally.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | commerce_migrate-example-1202101-12.patch | 304.02 KB | smccabe |
Comments
Comment #1
bojanz commentedThe custom file function, does it do anything that the MigrateFileFieldHandler class doesn't?
I only glanced at this, so they actually might be doing two completely different things, but it's worth checking out.
I've given you commit access to the project.
Comment #2
rfayHere's the working version that does products and display nodes.
The intention is to teach, not to provide a useful migration.
I am absolutely certain that something better can be done with the file stuff. And since I didn't even know about MigrateFileFieldHandler I'll have to learn something :-)
What kind of sucker do you think I am, just giving me commit access :-)
Comment #3
bojanz commentedJust didn't want you to be blocked by my lack of time for this project :)
I'll try to do an indepth review as soon as possible.
Comment #4
rfay:-)
I'm well aware of the key places you're taking care of far more significant modules than this one, and it's *very* much appreciated.
Comment #5
joachim commentedComment doesn't match up with code here.
Also, 'type' destination should be set on the product entity, as Migrate will complain it's not mapped to -- not sure what to though, see here: #1650850: product entity has superflous destination fields.
Comment #6
adrupaler commentedI have some custom fields in my "product" type. how should I add them in the columns of the CSV file?
I will really appreciate for some help or advice on mapping custom fields of "product" type. maybe one solution is use of PrepareRow or Prepare function.
Comment #7
mglamanComment #8
smccabe commentedDid a bunch of cleanup and some additional work on this. Still needs more work but this is a bunch farther along.
Comment #9
smccabe commentedAight, the example works now, nothing flashy but it will link up the product and product display, set the pricing, etc.
Comment #10
smccabe commentedSame as above but with some sample images setup, not sure which way is preferred.
Comment #11
mglamanLooks good. This example should help others along the way. I had to base my examples off of CK2, nice to have a simpler one.
EDIT: smccabe will need to upload patch with --binary in order to properly commit, FYI.
Comment #12
smccabe commentedBinary version attached
Comment #13
mglamanw00t committed.
Comment #16
firfin commentedIs there an example (or documentation) how to create a custom migration (into commerce 2) for drupal 8 using yaml files?
Comment #17
bojanz commentedhttps://www.blueoakinteractive.com/blog/custom-drupal-commerce-2x-migrat... might help
Comment #18
firfin commentedThanks @bojanz, but that link was more a tutorial on a custom migration. Not very specific to commerce IMHO.
I found this one more informative https://github.com/mglaman/commerce_demo/tree/master/migrations
But most important was the realization, that you have to migrate the variations first and the products second, still seems strange to me. Wish I knew that hours ago ;-)