You are here

csv_example_image.yml in Commerce Migrate 3.0.x

modules/csv_example/migrations/csv_example_image.yml

File

modules/csv_example/migrations/csv_example_image.yml
View source
  1. # Imports image files into the files_managed table.
  2. #
  3. # Imports up to 3 files per row. Each file name is a separate column. If your
  4. # migration has many files it is a good idea to copy them to the destination
  5. # by some fast method, i.e. rsync. The files can be put directly into the final
  6. # directory, i.e. public://. This migration does not need to move or copy the
  7. # file but it must be run in order to initialize the file entity for each file.
  8. #
  9. # When the source and destination directory are the same be aware that a
  10. # rollback of this migration will delete the files from the source directory.
  11. # Please plan your development and production work flows with that in mind.
  12. #
  13. # Destination site configuration:
  14. # - Install the File Module.
  15. #
  16. id: csv_example_image
  17. label: Images for products and variations
  18. migration_group: commerce_migrate_csv_example
  19. migration_tags:
  20. - Commerce CSV
  21. - Content
  22. source:
  23. plugin: csv_example_image
  24. path: 'public://import/example-products.csv'
  25. enclosure: "\""
  26. header_offset: 0
  27. ids: [sku, image]
  28. constants:
  29. base_path: 'public://import/images'
  30. fields:
  31. - name: title
  32. label: Title
  33. - name: sku
  34. label: SKU
  35. - name: status
  36. label: Status
  37. - name: product_type
  38. label: Product type
  39. - name: description
  40. label: Description
  41. - name: product_variation_type
  42. label: Product variation type
  43. - name: sell_price
  44. label: Sell price
  45. - name: vocabulary_name1
  46. label: Vocabulary1
  47. - name: term1
  48. label: Vocabulary value1
  49. - name: vocabulary_name2
  50. label: Vocabulary2
  51. - name: term2
  52. label: Vocabulary value2
  53. - name: vocabulary_name3
  54. label: Vocabulary3
  55. - name: term3
  56. label: Vocabulary value3
  57. - name: attribute_name1
  58. label: Attribute name1
  59. - name: attribute_value1
  60. label: Attribute value1
  61. - name: attribute_name2
  62. label: Attribute name2
  63. - name: attribute_value2
  64. label: Attribute value2
  65. - name: attribute_name3
  66. label: Attribute name3
  67. - name: attribute_value3
  68. label: Attribute value3
  69. - name: attribute_name4
  70. label: Attribute name4
  71. - name: attribute_value4
  72. label: Attribute value4
  73. - name: related1
  74. label: SKU of Related item 1
  75. - name: related2
  76. label: SKU of Related item 2
  77. - name: related3
  78. label: SKU of Related item 3
  79. - name: image1
  80. label: Image 1
  81. - name: image2
  82. label: Image 2
  83. - name: image3
  84. label: Image 3
  85. - name: video1
  86. label: Video 1
  87. - name: thumbnail1
  88. label: Thumbnail 1
  89. - name: video2
  90. label: Video 2
  91. - name: thumbnail2
  92. label: Thumbnail 2
  93. - name: video3
  94. label: Video 3
  95. - name: thumbnail3
  96. label: Thumbnail 3
  97. - name: tab_title1
  98. label: Tab title 1
  99. - name: tab_content1
  100. label: Tab content 1
  101. - name: tab_cta1
  102. label: Associated tab CTA 1
  103. - name: tab_title2
  104. label: Tab title 2
  105. - name: tab_content2
  106. label: Tab content 2
  107. - name: tab_cta2
  108. label: Associated tab CTA 2
  109. - name: cta_title1
  110. label: CTA title 1
  111. - name: cta_link1
  112. label: CTA link 1
  113. - name: cta_image1
  114. label: CTA product image 1
  115. - name: cta_title2
  116. label: CTA title 2
  117. - name: cta_link2
  118. label: CTA link 2
  119. - name: cta_image2
  120. label: CTA product image 2
  121. process:
  122. # Path to the source file.
  123. full_path:
  124. -
  125. plugin: concat
  126. delimiter: /
  127. source:
  128. - 'constants/base_path'
  129. - image
  130. -
  131. plugin: urlencode
  132. filename: image
  133. # Copy the files from the source to the destination. Here the source files
  134. # have been moved to the destination by some other, probably faster, means.
  135. # If the source and destination are the same, no copy action takes place.
  136. uri:
  137. plugin: file_copy
  138. source:
  139. - '@full_path'
  140. - '@full_path'
  141. # Assign a uid to the file, default to 1.
  142. uid:
  143. plugin: default_value
  144. source: image_uid
  145. default_value: 1
  146. status:
  147. plugin: default_value
  148. default_value: 1
  149. destination:
  150. plugin: 'entity:file'