You are here

csv_example_product_variation.yml in Commerce Migrate 3.1.x

modules/csv_example/migrations/csv_example_product_variation.yml

File

modules/csv_example/migrations/csv_example_product_variation.yml
View source
  1. # Import a product variation with up to 4 attribute values and 3 images.
  2. #
  3. # If any of the attributes or images do not exist in the source, processing
  4. # for that item is skipped, the remaining data is still imported.
  5. #
  6. # To modify
  7. #
  8. # Destination site configuration:
  9. # - Same requirements as the csv_image migration.
  10. # - Same requirements as the csv_attribute_value migration.
  11. # - Install the Paragraph Module.
  12. # - Create a product variation type with
  13. # - Up to 4 attributes.
  14. # - An image field, field_product_image.
  15. # - An image field, field_product_image_2.
  16. # - An image field, field_product_image_3.
  17. #
  18. id: csv_example_product_variation
  19. label: Product variations
  20. migration_group: commerce_migrate_csv_example
  21. migration_tags:
  22. - Commerce CSV
  23. - Content
  24. source:
  25. plugin: csv_example_product_variation
  26. path: 'public://import/example-products.csv'
  27. enclosure: "\""
  28. header_offset: 0
  29. ids: [ sku ]
  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. # The example data does not have a variation id. If your data has a column for
  123. # a variation ID uncomment this section.
  124. #variation_id:
  125. # plugin: skip_on_empty
  126. # source: <name of column with the ID>
  127. # method: row
  128. sku: sku
  129. title: title
  130. # The currency code defaults to 'CAD'. If your data has only 1 currency code,
  131. # then simply change the default value to that currency code. If multiple
  132. # currencies are used, this will need to be changed to the name given to that
  133. # that column of the input CSV.
  134. currency_code:
  135. plugin: default_value
  136. default_value: CAD
  137. price:
  138. plugin: csv_example_get_price
  139. source:
  140. - sell_price
  141. - '@currency_code'
  142. # The product variation type default to 'default'. For each product variation
  143. # type, make a new migration and change the default value to the desired
  144. # machine name.
  145. type:
  146. plugin: default_value
  147. default_value: default
  148. # Attributes are single valued entity reference fields migrated in name/id
  149. # pairs. The attribute name must be a machine name of a certain format.
  150. attribute1_name:
  151. plugin: machine_name
  152. source: attribute_name1
  153. attribute1_id:
  154. plugin: migration_lookup
  155. migration: csv_example_attribute_value
  156. source:
  157. - '@attribute1_name'
  158. - attribute_value1
  159. attribute2_name:
  160. plugin: machine_name
  161. source: attribute_name2
  162. attribute2_id:
  163. plugin: migration_lookup
  164. migration: csv_example_attribute_value
  165. source:
  166. - '@attribute2_name'
  167. - attribute_value2
  168. attribute3_name:
  169. plugin: machine_name
  170. source: attribute_name3
  171. attribute3_id:
  172. plugin: migration_lookup
  173. migration: csv_example_attribute_value
  174. source:
  175. - '@attribute3_name'
  176. - attribute_value3
  177. attribute4_name:
  178. plugin: machine_name
  179. source: attribute_name4
  180. attribute4_id:
  181. plugin: migration_lookup
  182. migration: csv_example_attribute_value
  183. source:
  184. - '@attribute4_name'
  185. - attribute_value4
  186. attribute_destination:
  187. plugin: csv_example_attribute_destination
  188. source:
  189. - '@attribute1_name'
  190. - '@attribute1_id'
  191. - '@attribute2_name'
  192. - '@attribute2_id'
  193. - '@attribute3_name'
  194. - '@attribute3_id'
  195. - '@attribute4_name'
  196. - '@attribute4_id'
  197. # For each image field the processing for that image is skipped if there
  198. # is no input and the rest of the row will continue to be processes.
  199. # Image field, single value.
  200. field_product_image:
  201. -
  202. plugin: skip_on_empty
  203. source: image1
  204. method: process
  205. -
  206. plugin: csv_example_product_variation_file
  207. source:
  208. - sku
  209. - image1
  210. # Image field, single value.
  211. field_product_image_2:
  212. -
  213. plugin: skip_on_empty
  214. source: image2
  215. method: process
  216. -
  217. plugin: csv_example_product_variation_file
  218. source:
  219. - sku
  220. - image2
  221. # Image field, single value.
  222. field_product_image_3:
  223. -
  224. plugin: skip_on_empty
  225. source: image3
  226. method: process
  227. -
  228. plugin: csv_example_product_variation_file
  229. source:
  230. - sku
  231. - image3
  232. destination:
  233. plugin: 'entity:commerce_product_variation'
  234. migration_dependencies:
  235. required:
  236. - csv_example_image
  237. - csv_example_attribute_value