Hi,

I am developing a complex migration, and the firts problem that i have is that in a TermMigration, my custom fields are not being saved, seems that this kind of fields are not using the language neutral array structure in the term generated object.

Here is my code, what is wrong?
for example, this line is not working: $this->addFieldMapping('field_autor_datos_biograficos', 'BIO_AUTOR1');


    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'ID_AUTOR1' => array('type' => 'varchar',
                           'length' => 255,
                           'not null' => TRUE,
                           'description' => 'Identificador de autor',
                          )
        ),
        MigrateDestinationTerm::getKeySchema()
    );

    $query = db_select('OBRAS');
    $query->distinct();
    $query->addField('OBRAS', 'ID_AUTOR1');
    $query->addField('OBRAS', 'NOM_AUTOR1');
    $query->addField('OBRAS', 'BIO_AUTOR1');
    $query->addField('OBRAS', 'BIO_AUTOR1_ENG');
    $query->condition('ID_AUTOR1', "", '!=');
    $query->orderBy('ID_AUTOR1', 'ASC');

    // Create a MigrateSource object, which manages retrieving the input data.
    $this->source = new MigrateSourceSQL($query);
    //$term_options = MigrateDestinationNode::options($language, $text_format);
    $this->destination = new MigrateDestinationTerm('Obra_Autor');
    $this->addFieldMapping('name', 'NOM_AUTOR1');
    $this->addFieldMapping('field_autor_id_simars', 'ID_AUTOR1');
    $this->addFieldMapping('field_autor_datos_biograficos', 'BIO_AUTOR1');

Best!

CommentFileSizeAuthor
#2 warning in migrate.png49.3 KBdavid.gil

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

You're using a Drupal version before 7.14, aren't you? See #1171866: Enforced fetching of fields/columns in lowercase breaks third-party integration - until 7.14, the database API automatically lower-cased field names, so you have to specify your mappings using lowercase.

david.gil’s picture

StatusFileSize
new49.3 KB

Hi Mike,

no i am using 7.14, and also i also try to lower case all, but still not working,
i see this warning (screenshot) in migrate ui that must be related, but not sure what to do.

class AutoresMigration extends MuseoMigration {
  public function __construct() {
    parent::__construct();

    $this->description = t('Importa los contenidos de autores en la taxonomía de autores');
    $this->dependencies = array('Paises');

    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'id_autor1' => array('type' => 'varchar',
                           'length' => 255,
                           'not null' => TRUE,
                           'description' => 'Identificador de autor',
                          )
        ),
        MigrateDestinationTerm::getKeySchema()
    );

    $query = db_select('OBRAS', 'obra')
          ->distinct()
         ->fields('obra', array('id_autor1', 'nom_autor1', 'bio_autor1', 'bio_autor1_eng'))
         ->condition('id_autor1', "", '!=')
         ->orderBy('id_autor1', 'ASC');


    
    // Create a MigrateSource object, which manages retrieving the input data.
    $this->source = new MigrateSourceSQL($query);
    //$term_options = MigrateDestinationNode::options($language, $text_format);
    $this->destination = new MigrateDestinationTerm('Obra_Autor');
    $this->addFieldMapping('name', 'nom_autor1');
    $this->addFieldMapping('description', 'bio_autor1');
    $this->addFieldMapping('field_autor_id_simars', 'id_autor1'); //@todo por lo que sea no lo coge
    $this->addFieldMapping('field_autor_datos_biograficos', 'bio_autor1'); //@todo por lo que sea no lo coge

best!

mikeryan’s picture

OK, since you are on 7.14, then your source field names must match the case that's in the source database.

The machine name of your vocabulary is precisely Obra_Autor, correct (it's not lower-case in Drupal)? What the warnings are saying is that you do not have fields named field_autor_id_simars and field_autor_datos_biograficos on that vocabulary.

david.gil’s picture

Assigned: Unassigned » david.gil
Status: Postponed (maintainer needs more info) » Closed (fixed)

Hi Mike,

you are rigtht the problem is with the taxonomy name, i was using the display name not the machine name, both are the same except in case. So some fields work and others not.

When i write it well all is working, no matter the case of fields in the DB, i write it in lower case in code and in upper in DB.

I close this, thanks a lot!!!
Best
David