csv_example_image.yml in Commerce Migrate 8.2
Same filename and directory in other branches
modules/csv_example/migrations/csv_example_image.yml
File
modules/csv_example/migrations/csv_example_image.ymlView source
- # Imports image files into the files_managed table.
- #
- # Imports up to 3 files per row. Each file name is a separate column. If your
- # migration has many files it is a good idea to copy them to the destination
- # by some fast method, i.e. rsync. The files can be put directly into the final
- # directory, i.e. public://. This migration does not need to move or copy the
- # file but it must be run in order to initialize the file entity for each file.
- #
- # When the source and destination directory are the same be aware that a
- # rollback of this migration will delete the files from the source directory.
- # Please plan your development and production work flows with that in mind.
- #
- # Destination site configuration:
- # - Install the File Module.
- #
- id: csv_example_image
- label: Images for products and variations
- migration_group: commerce_migrate_csv_example
- migration_tags:
- - Commerce CSV
- - Content
- source:
- plugin: csv_example_image
- path: 'public://import/example-products.csv'
- enclosure: "\""
- header_offset: 0
- ids: [sku, image]
- constants:
- base_path: 'public://import/images'
- fields:
- - name: title
- label: Title
- - name: sku
- label: SKU
- - name: status
- label: Status
- - name: product_type
- label: Product type
- - name: description
- label: Description
- - name: product_variation_type
- label: Product variation type
- - name: sell_price
- label: Sell price
- - name: vocabulary_name1
- label: Vocabulary1
- - name: term1
- label: Vocabulary value1
- - name: vocabulary_name2
- label: Vocabulary2
- - name: term2
- label: Vocabulary value2
- - name: vocabulary_name3
- label: Vocabulary3
- - name: term3
- label: Vocabulary value3
- - name: attribute_name1
- label: Attribute name1
- - name: attribute_value1
- label: Attribute value1
- - name: attribute_name2
- label: Attribute name2
- - name: attribute_value2
- label: Attribute value2
- - name: attribute_name3
- label: Attribute name3
- - name: attribute_value3
- label: Attribute value3
- - name: attribute_name4
- label: Attribute name4
- - name: attribute_value4
- label: Attribute value4
- - name: related1
- label: SKU of Related item 1
- - name: related2
- label: SKU of Related item 2
- - name: related3
- label: SKU of Related item 3
- - name: image1
- label: Image 1
- - name: image2
- label: Image 2
- - name: image3
- label: Image 3
- - name: video1
- label: Video 1
- - name: thumbnail1
- label: Thumbnail 1
- - name: video2
- label: Video 2
- - name: thumbnail2
- label: Thumbnail 2
- - name: video3
- label: Video 3
- - name: thumbnail3
- label: Thumbnail 3
- - name: tab_title1
- label: Tab title 1
- - name: tab_content1
- label: Tab content 1
- - name: tab_cta1
- label: Associated tab CTA 1
- - name: tab_title2
- label: Tab title 2
- - name: tab_content2
- label: Tab content 2
- - name: tab_cta2
- label: Associated tab CTA 2
- - name: cta_title1
- label: CTA title 1
- - name: cta_link1
- label: CTA link 1
- - name: cta_image1
- label: CTA product image 1
- - name: cta_title2
- label: CTA title 2
- - name: cta_link2
- label: CTA link 2
- - name: cta_image2
- label: CTA product image 2
- process:
- # Path to the source file.
- full_path:
- -
- plugin: concat
- delimiter: /
- source:
- - 'constants/base_path'
- - image
- -
- plugin: urlencode
- filename: image
- # Copy the files from the source to the destination. Here the source files
- # have been moved to the destination by some other, probably faster, means.
- # If the source and destination are the same, no copy action takes place.
- uri:
- plugin: file_copy
- source:
- - '@full_path'
- - '@full_path'
- # Assign a uid to the file, default to 1.
- uid:
- plugin: default_value
- source: image_uid
- default_value: 1
- status:
- plugin: default_value
- default_value: 1
- destination:
- plugin: 'entity:file'