In Drupal 6 an image item or image cache item can contain multiple images. I know that single images migrate properly, however I get at least one error on image widgets that contain a list of images. The following are messages from a single ubercart product item that contained multiple images in the field_image_cache field. The most common error I see is the Field Validation errors message.

Informational Undefined offset: 12 File /home/spe2sp/public_html/modules/taxonomy/taxonomy.module, line 1530(file: /home/spe2sp/public_html/modules/taxonomy/taxonomy.module, line 1530)

Trying to get property of non-object File /home/spe2sp/public_html/modules/taxonomy/taxonomy.module, line 1530(file: /home/spe2sp/public_html/modules/taxonomy/taxonomy.module, line 1530)

Field validation errors (/home/spe2sp/public_html/modules/field/field.attach.inc:801)

Comments

mikeryan’s picture

Title: Is there an example of migrating an image widet which has multiple images? » Is there an example of migrating an image field which has multiple images?
Status: Active » Postponed (maintainer needs more info)

How are you mapping the image fields - through the UI or through code? What are the specific field mappings you've set up? Regarding the field validation errors, what constraint(s) have you set on the destination image field? Is it set to required?

pcher1bw’s picture

Field is not required.
The field mappings are in code, the following is declared in an abstract class that applies to 17 content types / product types that are being migrated. Currently I do not have any code for uc_product_image or field_image_cache in prepareRow() or prepare(). Receiving widget type in D7 is image, sending widget type in D6 is also image.

    $this->addUnmigratedSources(array = ('field_image_cache:list'));
    $this->addFieldMapping('uc_product_image', 'field_image_cache')
         ->sourceMigration('file_managed');
    $this->addFieldMapping('uc_product_image:alt', 'field_image_cache:alt');
    $this->addFieldMapping('uc_product_image:title', 'field_image_cache:title');
    $this->addFieldMapping('uc_product_image:file_class')
         ->defaultValue('MigrateFileFid');
    $this->addFieldMapping('uc_product_image:preserve_files')
         ->defaultValue(TRUE);
    $this->addFieldMapping('uc_product_image:language', 'language')
         ->defaultValue(LANGUAGE_NONE);

Debugging code using watchdog shows me this in prepareRow().

[field_image_cache] => Array ( [0] => 3151 [1] => 3152 [2] => 3153 [3] => 3154 [4] => 3155 [5] => 3156 [6] => 3157 [7] => 3158 [8] => 3159 [9] => 3160 [10] => 3161 [11] => 3162 [12] => 3163 [13] => 3164 [14] => 3165 [15] => 3166 [16] => 3167 )
[field_image_cache:list] => Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 [13] => 1 [14] => 1 [15] => 1 [16] => 1 )
[field_image_cache:alt] => Array (
  [0] => Halter Bridle Combo BioThane Beta Bit Hangers BioThane Gold Wine. Classic
  [1] => Horse Shoe Brand - Half Buckles - BRUSHED Finish (Shown) or Black Inlay
  [2] => Horse Shoe Brand - Conway buckle & TL & Bit -BRUSHED (Shown) or Black Inlay
  [3] => Thumb Touch Easy -Stainless Steel Halter Snap at Throat Latch
  [4] => Strong Stainless Steel Halter Squares
  [5] => Stainless Steel Halter Loop for your lead-rope when you tie-up
  [6] => Swivel Snap to Bit Hanger
  [7] => Elongated Dee Ring on Halter Bridle for Easy Bit Hanger Attachment - Stainless
  [8] => Horse Shoe Brand Concho Covered Snap on Changeable Browband Black Inlay (Shown)
  [9] => Horse Shoe Brand on Changeable Browband Closure with Concho covered Snap BLACK
  [10] => BioThane Beta Black leather-like Matte Finish BL520
  [11] => BioThane Beta Chocolate Brown leather-like Matte Finish BR523
  [12] => BioThane Beta Caramel Brown leather-like Matte Finish BR522 Equine Strength
  [13] => BioThane Beta Gloss Black Finish BL101 Equine Strength
  [14] => BioThane Beta Dusty Blue shiny Finish BU103 Equine Strength
  [15] => BioThane Beta - Navy Finish BU101 Shiny Gold Series Bio Equine Strength
  [16] => BioThane Beta - Wine Finish WN101 Shiny Gold Series Bio Equine Strength
)
[field_image_cache:title] => Array (
  [0] => The Classic Series Halter Bridle with Bit Hangers shown in BioThane Gold Wine
  [1] => Horse Shoe Brand - Half Buckles - BRUSHED Finish (Shown) or Black Inlay
  [2] => Horse Shoe Brand - Conway buckle at Throat Latch & to Bit - BRUSHED (Shown) or Black Inlay
  [3] => Thumb Touch Easy - yet strong -Stainless Steel Halter Snap at Throat Latch
  [4] => Strong Stainless Steel Halter Squares with rounded edges for smoothness
  [5] => Strong Stainless Steel Halter Loop for your lead-rope when you tie-up
  [6] => Swivel Swivel Snap closes on to Dee ring on bit hangers
  [7] => Elongated Dee Ring on Halter Bridle for Easy Bit Hanger Attachment when you attach the bit.
  [8] => Horse Shoe Brand 1" Concho Covered Snap on Changeable Browband Closure - BLACK INLAY (Shown) or BRUSHED finish
  [9] => Changeable Halter Bridle with Bit Hangers Browband Closure with 1" Horse Shoe Brand Concho Covered Snap - BRUSHED (Shown) or BLACK INLAY
  [10] => BioThane Beta Black leather-like Matte Finish BL520
  [11] => BioThane Beta Chocolate Brown leather-like Matte Finish BR523
  [12] => BioThane Beta Caramel Brown leather-like Matte Finish BR522
  [13] => BioThane - Gloss Black Finish BL101 Gold Series Bio
  [14] => BioThane - Dusty Blue Finish BU103 Gold Series Bio
  [15] => BioThane Beta - Navy Finish BU101 Gold Series Bio
  [16] => BioThane Beta - Wine Finish WN101 Shiny Gold Series Bio (as shown on horse Model) 
)

pcher1bw’s picture

Status: Postponed (maintainer needs more info) » Active
mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

OK, the incoming data looks good. The next thing to try is seeing how the destination object has been populated:

public function prepare($node, $row) {
  drush_print_r($node->uc_product_image);
}
pcher1bw’s picture

My mistake, the problem is not with images, it is with taxonomy references. In the prepareRow & prepare debug info the TID for 8/field_product_collection remains 126, which will cause the validation to fail (126 should map to 316). Do I need the source taxonomy ('8') in the field mapping for source_type, create_term and ignore_case?

The following code works fine:

    $this->addFieldMapping('taxonomy_catalog', '1')
         ->sourceMigration('Catalog');
    $this->addFieldMapping('taxonomy_catalog:source_type','1')->defaultValue('tid');
    $this->addFieldMapping('taxonomy_catalog:create_term','1')->defaultValue(FALSE);
    $this->addFieldMapping('taxonomy_catalog:ignore_case','1')->defaultValue(FALSE);

This taxonomy reference does not always work:

    $this->addFieldMapping('field_product_collection', '8')
         ->sourceMigration('Collections');
    $this->addFieldMapping('field_product_collection:source_type')->defaultValue('tid');
    $this->addFieldMapping('field_product_collection:create_term')->defaultValue(FALSE);
    $this->addFieldMapping('field_product_collection:ignore_case')->defaultValue(FALSE);

prepareRow Debug info (row)

prepareRow Array ([Row Data] => stdClass Object (
  [nid] => 771
  [vid] => 771
  [language] =>
  [title] => Breast Collar - Endurance Style - Caramel Brown - Classic Series
  [uid] => 1
  [status] => 1
  [created] => 1311188071
  [changed] => 1417053097
  [comment] => 0
  [promote] => 0
  [moderate] => 0
  [sticky] => 0
  [translate] => 0
  [body] =>
BioThane Beta Breastplate for Trail Riding in Caramel Brown - Unlined

Classic Beta Series - Endurance Breast Collar Style - UNLINED - Caramel Brown BioThane Beta with Horse Shoe Black Inlay Half Buckle and Horse Shoe Black Inlay Breast Collar Ring.



Important Order Note: The Caramel Brown is now a Special Order Color.  Your order will arrive in 21 days or less however is not in-stock for next day shipment.
[teaser] =>
  [format] => 2
  [field_product_shoulder_straps] => Horse Shoe Half Buckles BLACK INLAY
  [field_product_breast_center] => Horse Shoe Breast Center RING BLACK INLAY
  [field_product_lined] => Unlined
  [daycount] =>
  [timestamp] =>
  [totalcount] =>
  [path] => Breast-Collar-Endurance-BioThane-Caramel-06
  [field_image_cache] => Array (
    [0] => 335
    [1] => 380
    [2] => 382
    [3] => 1246
    [4] => 381
  )
  [field_image_cache:list] => Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 )
  [field_image_cache:alt] => Array (
    [0] => Classic Beta Series- Endurance Breast Collar UNLINED-Caramel Brown BioThane Beta
    [1] => Horse Shoe Breast Collar Ring at Breast Center - BLACK INLAY
    [2] => Easy Adjust - Horse Shoe Half Buckle Detail - BLACK INLAY
    [3] => Thumb Touch - Stainless Steel Snap to Saddle and Girth or Cinch
    [4] => Endurance Style Breast Collar - Side View of Saddle D Ring Connection
  )
  [field_image_cache:title] => Array (
      [0] => Classic Beta Series- Endurance Breast Collar UNLINED-Caramel BioThane Beta
      [1] => Horse Shoe Breast Collar Ring at Breast Center - BLACK INLAY
      [2] => Easy Adjust - Horse Shoe Half Buckle Detail - BLACK INLAY
      [3] => Thumb Touch - Stainless Steel Snap to Saddle and Girth or Cinch
      [4] => Endurance Style Breast Collar - Side View of Saddle D Ring Connection
  )
  [field_product_mfg_partno] => Array ( [0] => 9276-BR522 )
  [field_product_color] => Array ( [0] => Caramel Brown Beta BR522 )
  [8] => Array ( [0] => 126 ) // field_product_collection
  [1] => Array ( [0] => 146 ) // taxonomy_catalog
  [tnid] => 0 )
)

prepare Debug info (node)

prepare stdClass Object (
  [body]
    => Array ( [und] => Array ( [0] => Array ( [summary] => [value_format] => full_html [format] => full_html [value] =>
BioThane Beta Breastplate for Trail Riding in Caramel Brown - Unlined

Classic Beta Series - Endurance Breast Collar Style - UNLINED - Caramel Brown BioThane Beta with Horse Shoe Black Inlay Half Buckle and Horse Shoe Black Inlay Breast Collar Ring.



Important Order Note: The Caramel Brown is now a Special Order Color.  Your order will arrive in 21 days or less however is not in-stock for next day shipment.
) ) )
  [changed] => 1417053097
  [comment] => 0
  [created] => 1311188071
  [field_product_breast_center] => Array ( [und] => Array ( [0] => Array (
    [value_format] =>
    [format] =>
    [value] => Horse Shoe Breast Center RING BLACK INLAY ) )
  )
  [field_product_collection] => Array ( [und] => Array ( [0] => Array ( [tid] => 126 ) ) )
  [field_product_color] => Array ( [und] => Array ( [0] => Array ( [value_format] => [format] => [value] => Caramel Brown Beta BR522 ) ) )
  [field_product_lined] => Array ( [und] => Array ( [0] => Array ( [value_format] =>
  [format] =>
  [value] => Unlined ) ) )
  [field_product_mfg_partno] => Array ( [und] => Array ( [0] => Array (
  [value_format] =>
  [format] =>
  [value] => 9276-BR522 ) ) )
  [field_product_shoulder_straps] => Array ( [und] => Array ( [0] => Array ( [value_format] => [format] => [value] => Horse Shoe Half Buckles BLACK INLAY ) ) )
  [language] => und
  [path] => Array (
  [alias] => Breast-Collar-Endurance-BioThane-Caramel-06 )
  [pathauto] => 0
  [promote] => 0
  [status] => 1
  [sticky] => 0
  [taxonomy_catalog] => Array ( [und] => Array ( [0] => Array ( [tid] => 498 ) ) )
  [title] => Breast Collar - Endurance Style - Caramel Brown - Classic Series
  [tnid] => 0
  [translate] => 0
  [uc_product_image] => Array (
    [] => Array (
    [0] => Array (
      [fid] => 257
      [alt] => Classic Beta Series- Endurance Breast Collar UNLINED-Caramel Brown BioThane Beta
      [title] => Classic Beta Series- Endurance Breast Collar UNLINED-Caramel BioThane Beta )
    [1] => Array (
      [fid] => 292
      [alt] => Horse Shoe Breast Collar Ring at Breast Center - BLACK INLAY
      [title] => Horse Shoe Breast Collar Ring at Breast Center - BLACK INLAY
    )
    [2] => Array (
      [fid] => 294
      [alt] => Easy Adjust - Horse Shoe Half Buckle Detail - BLACK INLAY
      [title] => Easy Adjust - Horse Shoe Half Buckle Detail - BLACK INLAY )
    [3] => Array (
      [fid] => 954
      [alt] => Thumb Touch - Stainless Steel Snap to Saddle and Girth or Cinch
      [title] => Thumb Touch - Stainless Steel Snap to Saddle and Girth or Cinch
    )
    [4] => Array (
      [fid] => 293
      [alt] => Endurance Style Breast Collar - Side View of Saddle D Ring Connection
      [title] => Endurance Style Breast Collar - Side View of Saddle D Ring Connection
    )
  ) )
  [uid] => 1
  [type] => breast_collars
  [revision] =>
  [model] =>
  [list_price] => 0
  [cost] => 0
  [sell_price] => 0
  [weight] => 0
  [weight_units] => lb
  [length] => 0
  [width] => 0
  [height] => 0
  [length_units] => in
  [pkg_qty] => 1
  [default_qty] => 1
  [shippable] => 1
  [ordering] => 0
  [menu] => Array (
  [link_title] =>
  [mlid] => 0
  [plid] => 0
  [menu_name] => main-menu
  [weight] => 0
  [options] => Array ( )
  [module] => menu
  [expanded] => 0
  [hidden] => 0
  [has_children] => 0
  [customized] => 0
  [parent_depth_limit] => 8 )
  [migrate] => Array ( [machineName] => BreastCollars )
)
pcher1bw’s picture

Status: Postponed (maintainer needs more info) » Active
mikeryan’s picture

Title: Is there an example of migrating an image field which has multiple images? » Problem migrating taxonomy term references
Status: Active » Postponed (maintainer needs more info)

OK, so taxonomy_catalog got properly translated from the source tid to the destination tid, but field_product_collection did not. The first thing to check is the map table you're referencing with sourceMigration('Collections') (presumably migrate_map_collections) and make sure the expected mapping is there for sourceid1=126. If it is, my next step would be debugging handleSourceMigration() to figure out why it's not getting that value.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
mvlabat’s picture

Status: Closed (cannot reproduce) » Postponed

I've met the same issue when a taxonomy reference field had wrong vocabulary machine name. It happened because of using a broken feature (Features module).
Try recreating your field, this may solve your problem.

mvlabat’s picture

P.S. If that caused this issue we may set "Closed (works as designed)".

mikeryan’s picture

Status: Postponed » Closed (cannot reproduce)

Restoring appropriate status.

shaundychko’s picture

I had a similar problem caused by using Taxonomy Access Control. The "Anonymous" user needed permission to add the taxonomy term since the migration runs as Anonymous.