Hi

I am right at the tail end of a migration of a Drupal6 Ubercart 2 site to Drupal 7 and Drupal Commerce.

I did most of the standard non commerce migration using Drupal Migrate Drupal 2 Drupal version 7-x.2.1 successfully.

I have successfully imported users and products from ubercart but it refuses to import the Nodes associated with the product so creates no product displays.

The product category is called Publication and the failing migration is CommerceMigrateUbercartNodePublication

whilst

CommerceMigrateUbercartProductPublication works fine.

There is an error raised when looking at CommerceMigrateUbercartNodePublication which is

"field_product" was used as destination field in "nid" mapping but is not in list of destination fields

whilst the migration when run from drush errors which all have the following error

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'Hare And Hound' for column 'sourceid1' at row 1: INSERT INTO {migrate_map_mysitenodepublication} (sourceid1, needs_update, rollback_action, hash, destid1) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array
(
[:db_insert_placeholder_0] => Hare And Hound
[:db_insert_placeholder_1] => 1
[:db_insert_placeholder_2] => 0
[:db_insert_placeholder_3] =>
[:db_insert_placeholder_4] => 1999
)
in MigrateSQLMap->saveIDMapping() (line 374 of /var/www/mysite.dev/sites/all/modules/migrate/plugins/sources/sqlmap.inc).

So to my eyes it seems that the node title is trying to map to the nid which seems in keeping with the error in the GUI.

I will probably chunk some sql to solve this but if anyone has a solution then please pour forth.

Otherwise I leave it up to the maintainers to ascertain if this is a bug or a special case.

Regards

Tim

Comments

Anonymous’s picture

It sounds like the node type you are importing to does not have a Product Reference field, which needs to have a machine name of field_product. By default it only supports inserting one item into that field (since in Übercart there was only one product per node).

technotim2010’s picture

Hi

I renamed the product reference field to field_product now it fails with an error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column [error]
'entity_id' cannot be null: INSERT INTO
{field_data_field_product_reference} (entity_type, entity_id,
revision_id, bundle, delta, language,
field_product_reference_product_id) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2,
:db_insert_placeholder_3, :db_insert_placeholder_4,
:db_insert_placeholder_5, :db_insert_placeholder_6),
(:db_insert_placeholder_7, :db_insert_placeholder_8,
:db_insert_placeholder_9, :db_insert_placeholder_10,
:db_insert_placeholder_11, :db_insert_placeholder_12,
:db_insert_placeholder_13); Array
(
[:db_insert_placeholder_0] => node
[:db_insert_placeholder_1] =>
[:db_insert_placeholder_2] =>
[:db_insert_placeholder_3] => product_display
[:db_insert_placeholder_4] => 0
[:db_insert_placeholder_5] => und
[:db_insert_placeholder_6] => 525
[:db_insert_placeholder_7] => node
[:db_insert_placeholder_8] =>
[:db_insert_placeholder_9] =>
[:db_insert_placeholder_10] => product_display
[:db_insert_placeholder_11] => 1
[:db_insert_placeholder_12] => und
[:db_insert_placeholder_13] => 525
)
(/var/www/mysite/modules/field/modules/field_sql_storage/field_sql_storage.module:451)

so it's looking for a field product_reference and failing to find one.
The migrate mapping still has a field Product Reference (commerce_product_reference) [field_product_reference]
which is mapped to n.nid [nid] with a source Migration of CommerceMigrateUbercartProductPublication (publication being the category before and now the product type)
Have i hit a circular reference and should I do this in some code if so how?

Cheers

Tim

technotim2010’s picture

Hi

I looked at the code in product_node.inc and can see part of the issue

Line 60 states

<?php // The product_display content type is created by commerce install profiles,
    // not the module itself, so hardcoding this might be unwise.
    $this->destination = new MigrateDestinationNode('product_display');?>

Since I already migrated a content type that I intend to use for the product_display but it is not called "product_display" then in this case the underlying assumption is indeed unwise.

I am not sure how you resolve that, ideally you need to expose the content type machine name in the UI and pass it in as a parameter, but until then ensure the documentation has a suitably worded warning. I suggest

Commerce Migrate Ubercart assumes that the content types for the product displays are non-existent and called product_display and not anything else. As a consequence the migrate Class CommerceMIgrateUbercartNodeMyContentType will fail if the name of the content type to be used as the product_display is anything else.

Sadly that is not all.

Adding a Product Reference Field to a content type in preparation for a migration and following Drupal Commerce documentation elsewhere suggests the field name be called field_product_reference, however the code in the same file product_node.inc on line 80 has

<?php  // Fields
    // We have no idea of which type the referenced product is, so
    // we specify all (for the sourceMigration).
    $this->addFieldMapping('field_product', 'nid')

         ->sourceMigration($arguments['products']);  ?> 

So that will not work either. No doubt the automatic product migration would work, sadly not in this case.

However changing the content type name and the product reference field name does not resolve the issue and causes yet more SQL errors.

I am not sure if there is any workaround for this. I have tried updating the sql table of the product_reference field directly with the nid of the product but this fails. I have tried using rules and VBO to update the field with the nid of the product but this also fails. (despite the titles in both content type and product matching 100% and can think of no other way to resolve this. I have over 1000 nodes to link product to content type nodes (the latter of which all have node_references to other content) and can only think that exporting the data out of D7 and importing via Commerce Feeds may be worth a try.

Any suggestions would be welcome for a solution.

Regards

Tim

Anonymous’s picture

@TechnoTim2010:

> However changing the content type name and the product reference field name does not resolve the issue and causes yet more SQL errors.

You will need to re-register the migrations from the configuration page if you change these values. Then it should work the next time you run it.

The rest of your comments... I agree... there are some challenges in how we could detect the names better. The code comments are there to at least direct people who are stuck to what the likely problem is. If you write a patch to address any of these items I welcome it.

technotim2010’s picture

Hi

You will need to re-register the migrations from the configuration page if you change these values. Then it should work the next time you run it.

This seems to zero all the configuration that I have set up elsewhere in the migration classes. Since migration is not compatible with Features or Configuration Management there seems to be no way of saving a configuration so you can change these settings.

Oddly the Migration led me to create a product reference field in my target Product Display Content Type called field_product_reference whereas I would otherwise have left it alone, but I think this may have been an issue raised by Drupal to Drupal Migration (not your module).

Anyway with the help of some peeps on IRC I created a fix for the issue of now having 500+ Product Display nodes and a 1000+ products and no mechanism (apart from the laborious manual method) of joining them. Fortunately having a one to one match on titles (product to product display) made this possible. I may well sandbox this as another IRC user had exactly the same issue.

Anonymous’s picture

Status: Active » Closed (works as designed)

This seems to zero all the configuration that I have set up elsewhere in the migration classes.

Then you have a problem elsewhere in your code base. If no migrations are currently running this command should always be safe to run.

Most of the time people code their migrations if there is a need to do something like features/config mgmt... but migrate_d2d is becoming a viable option, and indeed, it does not have a way to export that stuff at the moment. Though I am sure the folks at migrate_d2d would welcome a patch if one does not exist already.

Closing this ticket as it sounds like you have worked it out. You may want to check the migrate_d2d issue queue for the other points.