Forked from dinarcon/migrate_plus.migration.omdb_json.yml
Created
April 10, 2018 22:56
-
-
Save maxstarkenburg/593919b25ea8032b18db156df5b38c3d to your computer and use it in GitHub Desktop.
Drupal 8 JSON Migration Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This migration demonstrates importing from a monolithic JSON file. | |
# Forked from https://github.com/heddn/json_example_migrate/blob/json/web/modules/custom/custom_migrate/config/install/migrate_plus.migration.omdb_json.yml | |
id: omdb_json | |
label: JSON feed of movies | |
migration_group: json_example | |
source: | |
# We use the JSON source plugin. | |
plugin: url | |
data_fetcher_plugin: http | |
data_parser_plugin: json | |
# The data_parser normally limits the fields passed on to the source plugin | |
# to fields configured to be used as part of the migration. To support more | |
# dynamic migrations, the JSON data parser supports including the original | |
# data for the current row. Simply include the 'include_raw_data' flag set | |
# to `true` to enable this. This option is disabled by default to minimize | |
# memory footprint for migrations that do not need this capability. | |
include_raw_data: true | |
urls: 'http://www.omdbapi.com/?s=space&type=movie&r=json&apikey=86e4b169' | |
# An xpath-like selector corresponding to the items to be imported. | |
item_selector: Search | |
# Under 'fields', we list the data items to be imported. The first level keys | |
# are the source field names we want to populate (the names to be used as | |
# sources in the process configuration below). For each field we're importing, | |
# we provide a label (optional - this is for display in migration tools) and | |
# an xpath for retrieving that value. It's important to note that this xpath | |
# is relative to the elements retrieved by item_selector. | |
fields: | |
- | |
name: movieName | |
label: 'Movie Name' | |
selector: Title | |
- | |
name: year | |
label: 'Publish Year' | |
selector: Year | |
- | |
name: imdbID | |
label: 'IMDB ID' | |
selector: imdbID | |
- | |
name: poster | |
label: 'Image URL to a movie poster' | |
selector: Poster | |
# Under 'ids', we identify source fields populated above which will uniquely | |
# identify each imported item. The 'type' makes sure the migration map table | |
# uses the proper schema type for stored the IDs. | |
ids: | |
imdbID: | |
type: string | |
constants: | |
bundle: article | |
destination_directory: public://posters/ | |
file_extension: .jpg | |
process: | |
# Note that the source field names here (title and year) were | |
# defined by the 'fields' configuration for the source plugin above. | |
type: constants/bundle | |
title: | |
plugin: concat | |
source: | |
- movieName | |
- year | |
delimiter: ' - ' | |
body/value: imdbID | |
body/format: | |
plugin: default_value | |
default_value: basic_html | |
destination_path: | |
plugin: concat | |
source: | |
- constants/destination_directory | |
- imdbID | |
- constants/file_extension | |
field_image/target_id: | |
- | |
plugin: file_copy | |
source: | |
- poster | |
- '@destination_path' | |
- | |
plugin: entity_generate | |
value_key: uri | |
entity_type: file | |
field_image/alt: title | |
field_image/title: title | |
destination: | |
plugin: entity:node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id: omdb_json_basic | |
label: JSON feed of movies (basic) | |
migration_group: json_example | |
source: | |
plugin: url | |
data_fetcher_plugin: http | |
data_parser_plugin: json | |
include_raw_data: true | |
urls: 'http://www.omdbapi.com/?s=space&type=movie&r=json&apikey=86e4b169' | |
item_selector: Search | |
fields: | |
- | |
name: movieName | |
label: 'Movie Name' | |
selector: Title | |
- | |
name: imdbID | |
label: 'IMDB ID' | |
selector: imdbID | |
ids: | |
imdbID: | |
type: string | |
destination: | |
plugin: entity:node | |
process: | |
type: | |
plugin: default_value | |
default_value: page | |
title: movieName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
langcode: en | |
status: true | |
dependencies: { } | |
id: json_example | |
label: JSON Example | |
description: '' | |
source_type: '' | |
module: null | |
shared_configuration: null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment