0

I'm trying to import a CSV file using Feeds Importer and I've got the content created correctly, but then I need to add more data into the CSV and re-import the content and I'm getting the old content created again...

All the fields can change and are not unique, so I've created a specific integer field that was mapped twice, once to the field itself and then again to the GUID. I've done this, in order to have one field that will be unique to each row and that I can fill with info from the CSV and ironically, that will allow me to stop the content to be duplicated...

This is the importer I'm using:

$feeds_importer = new stdClass();
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'csv_a_bienes';
$feeds_importer->config = array(
  'name' => 'CSV a Bienes',
  'description' => '',
  'fetcher' => array(
    'plugin_key' => 'FeedsFileFetcher',
    'config' => array(
      'allowed_extensions' => 'csv',
      'direct' => 0,
      'directory' => 'private://CSV',
      'allowed_schemes' => array(
        'public' => 'public',
      ),
    ),
  ),
  'parser' => array(
    'plugin_key' => 'FeedsCSVParser',
    'config' => array(
      'delimiter' => ',',
      'no_headers' => 0,
    ),
  ),
  'processor' => array(
    'plugin_key' => 'FeedsNodeProcessor',
    'config' => array(
      'expire' => '-1',
      'author' => '1',
      'authorize' => 0,
      'mappings' => array(
        0 => array(
          'source' => 'guid',
          'target' => 'guid',
          'unique' => 1,
        ),
        1 => array(
          'source' => 'guid',
          'target' => 'field_guid',
          'unique' => FALSE,
        ),
        2 => array(
          'source' => 'Postulados',
          'target' => 'field_postulados',
          'unique' => FALSE,
        ),
        3 => array(
          'source' => 'Bloque',
          'target' => 'field_bloque',
          'unique' => FALSE,
        ),
        4 => array(
          'source' => 'Departamento',
          'target' => 'field_departamento',
          'unique' => FALSE,
        ),
        5 => array(
          'source' => 'Municipio',
          'target' => 'field_municipio_lugar',
          'unique' => FALSE,
        ),
        6 => array(
          'source' => 'Tipo de bien',
          'target' => 'field_tipo_bienfrv',
          'unique' => FALSE,
        ),
        7 => array(
          'source' => 'Clase del bien',
          'target' => 'field_clase_del_bien',
          'unique' => FALSE,
        ),
        8 => array(
          'source' => 'Subclase del bien',
          'target' => 'field_subclase_del_bien',
          'unique' => FALSE,
        ),
        9 => array(
          'source' => 'Nombre del Bien',
          'target' => 'title',
          'unique' => FALSE,
        ),
        10 => array(
          'source' => 'Consecutivo',
          'target' => 'field_consecutivo',
          'unique' => FALSE,
        ),
        11 => array(
          'source' => 'Numero de acta',
          'target' => 'field_n_mero_de_acta',
          'unique' => FALSE,
        ),
        12 => array(
          'source' => 'Documentos',
          'target' => 'field_archivo:uri',
          'unique' => FALSE,
        ),
        13 => array(
          'source' => 'Forma en que se recibio el bien',
          'target' => 'field_tipo_de_bien',
          'unique' => FALSE,
        ),
      ),
      'update_existing' => '2',
      'update_non_existent' => 'skip',
      'input_format' => 'plain_text',
      'skip_hash_check' => 0,
      'bundle' => 'bienes',
    ),
  ),
  'content_type' => 'bienes',
  'update' => 0,
  'import_period' => '-1',
  'expire_period' => 3600,
  'import_on_create' => 1,
  'process_in_background' => 0,
);

Can anyone please help me to identify what did I wrong?

  • You should use node ID as your unique field. – No Sssweat Dec 22 '15 at 20:35
1

Add a node title as unique field in feeds and set your processor settings as "Update existing nodes". This will update your nodes when you change the fields value in csv.

0

You can use unique field module in Drupal 7,

https://www.drupal.org/project/unique_field

Also please refer to this link for unique target.

https://www.drupal.org/node/661606

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.