I'm sorry for the 'critical' priority. I've never in my life had so much trouble with what seems like it should be such a simple problem. After 50 hours of life literally spent, I'm not a single typed character closer than before I started.
Here is the scenario:
I have a classified ads website. I created a content type called "for_sale." Of course, in my drupal database, this created a table called "content_type_for_sale." Ok.
Of course my content type has a TITLE and a BODY - the node defaults. I used CCK to create a "PRICE" field, which then created the column "content_field_price" in my content_type_for_sale table.
I also used CCK, filefield, and imageapi (typical reciple for this) to create a field where the user can upload one or more photos. Because of the multiple photo capability, CCK created a table called 'content_field_add_photos' to my database. Sure. I understand that. It's a one to many relationship, so it has to exist outside the content_type_for_sale table.
My problem
I have a custom mysql table of nodes which simply has an ID, TITLE, and BODY. I also have another mysql custom table that's responsible for the photos. To be absolutely thorough, here are my two table definitions:
mytable_node
+---------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+------------------+------+-----+---------+----------------+
| id_mytable_node | int(10) unsigned | NO | PRI | NULL | auto_increment |
| title | varchar(255) | NO | | NULL | |
| body | text | NO | | NULL | |
| content_field_price | float unsigned | YES | | NULL | |
+---------------------+------------------+------+-----+---------+----------------+
mytable_node_photos:
+------------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+------------------+------+-----+---------+----------------+
| id_mytable_node_photos | int(10) unsigned | NO | PRI | NULL | auto_increment |
| id_mytable_node | int(10) unsigned | NO | | NULL | |
| uid | int(10) unsigned | NO | | 0 | |
| filename | varchar(255) | NO | | NULL | |
| filepath | varchar(255) | NO | | NULL | |
| filesize | varchar(255) | NO | | 0 | |
| status | int(10) unsigned | NO | | 1 | |
| timestamp | int(10) unsigned | NO | | NULL | |
+------------------------+------------------+------+-----+---------+----------------+
As you can see, I'm using a key to create the relationship showing one node can have multiple photos. These two tables are the ones I prepared for Table Wizard and Migrate tools.
My question:
How do I get my data, and related photos into the Drupal database?
Current approaches to the problem (though unsuccessful)
Initially, I created a form, and simply started to copy, paste, upload, and submit. With more than 20,000 nodes and one or more photos for each node, It would literally take years to get what I need done that way.
I then thought I'd simply bypass the form all together, and create custom PHP code to aggregate my data, and iterate through it until all of Drupal's necessary tables were populated. If I could get the appropriate Node, related CCK fields, and the Files tables filled with the right data, and files uploaded to site/all/default/files it should have worked, right? No. That was another nightmare.
This led me to Table Wizard and Migrate modules
And, so, this quest has led me here. Understanding that this process requires the data to be in a MYSQL database, well, that's NO problem, as the tables above show. In fact, I modeled a lot of my table structure after those already in Drupal so there would be little room for error.
After reading Angie Byron's fantastic article explaning how to use these modules together for migration (http://www.lullabot.com/articles/drupal-data-imports-migrate-and-table-w...), and installing the "migrate extras modules" I successfully mapped my node data to my Node:for_sale type, including, the CCK:price field.
However, my CCK:content_field_add_photos is no where to be found. And this is where I'm stuck
How do I migrate the multiple photos for each node with each node so that my FILES table and content_field_add_photos table is populated correctly? Is this a relationship issue? Is this where I'm supposed to create a hook? I've never written a hook for anything. If I do write a hook, does it require me to create a new module?
I looked at the xoop example you guys gave, but it was a bit too deep for me. I also found comment 5 here (http://drupal.org/node/528726) to appear to be close to what I was doing, but it lost me when it started talking about hooks.
If there are ANY tutorials out there that offer step-by-step procedures for migrating a node and it's related photos please share them with me, otherwise, I believe from Angie's article to watching the talk about migrate and TW from drupalcon 2009, I've read everything the net has to offer.
So, again, how in the world do I get my mysql prepared data into Drupal with the Migrate and Table Wizard tools? If this was good enough to handle the Economist.com data, surely to God it can do this simple task.
Thanks,
Blue
Comments
Comment #1
mikeryanYes, you need to create a module and implement hook_migrate_prepare_node(). In the issue you referenced (http://drupal.org/node/528726), you'll find useful info (and links to even more useful info). Basically, in the prepare_node hook you will need to query the related mytable_node_photos rows and set up the file field.
Comment #2
mikeryan