0

Because migration skip emty or NULL label records on db, I need to migrate via csv file. So I do export of table records in csv like :

vid;nid;delta;field_lien_externe_url;field_lien_externe_title;field_lien_externe_attributes
7;7;0;http://www.onisep.fr;La fiche ONISEP;a:0:{}
171;16;0;http://www.onisep.fr;"";a:0:{}
171;16;1;;;
171;16;2;;;

Then I create a module with this treefolder :

my_module:
  |- my_module.info.yml
  |- my_module.install
  |- config
        |- install
             |- migrate_plus.migration.field_lien_externe.yml
  |- import
      |- program
           |- my_csv_file.csv

Then I need hepl for migrate_plus.migration.field_lien_externe.yml content.

Here my starting point from csv files migration:

id: field_lien_externe_migration
label: Champs liens pour contenu - nodes
migration_group: migration_linkfield
migration_tags:
  - file
  - migration_ce
# Source.
source:
  plugin: csv
  path: 'public://modules/custom/migration_link_fields/import/program/ce_field_lien_externe.csv'
  header_row_count: 1
  # Unique ID.
  #
  # The source for images do not have any existing unique IDs. Hence,
  # we use the image name as unique IDs. This will ensure that every
  # image results in the creation of a unique file entity on the site.
  keys:
    - vid
  # Source field definitions.
  fields:
    vid: ID associated to the linkfield and node

  # Since we are writing YAML, we do not have ways to manipulate
  # fields like we do in PHP. However, we can use migration process
  # plugins. These plugins can use migration-specific "constants"
  # to generate file paths and URIs.
  #
  # Here, we define constants which we would use to generate file paths
  # and file names for program images.
  constants:
    file_source_uri: public://import/program
    file_dest_uri: 'public://files'
# Destination.
destination:
  # We will be creating entities of type "file" this time.
  plugin: 'entity:field'
# Mappings.
process:
  file_source:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/files
        - filename
    # Make sure we don't have any url-unfriendly characters.
    -
      plugin: urlencode
  file_dest:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/file_dest_uri
        - filename
    # Make sure we don't have any url-unfriendly characters.
    -
      plugin: urlencode
  # We use the filename names as is.
  #
  # Alternatively, if we wish to name them after some other
  # column, we can do it here.
  filename: filename
  uri:
    plugin: file_copy
    source:
      - '@file_source'
      - '@file_dest'

I think I need to do something more simple,but can I use the same starting code from node migration ? like :

field_lien_externe:
       plugin: sub_process
       source: field_lien_externe
       process:
        uri: url
        title: title
        options: attributes

Thanks

EDIt: test with another code in custom node migration:

  field_lien_externe:
  -      
    plugin: sub_process
    source: field_lien_externe
    process:
       uri: url
       title: title
       options: attributes
  -
    plugin: skip_on_empty
    method: process

but it doesn't change anything, in addition, default migrate only 23 records instead of 312.Among 312 D6 table records, 199 aren't empty or NULL label.So Default migration could import 199 record if it skip on empty.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.