Problem/Motivation
Migrating XML file into drupal 9 and using Migration plus module. In my YML file I am passing the source and destination like this mentioned below.
uuid: 9a703170-9409-4baf-9b24-d042c0978cfe
langcode: en
status: true
dependencies: { }
id: test_products
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: test
label: Products
source:
batch_size: 100
constants:
bool_0: 0
bool_1: 1
uid_root: 1
plugin: url
data_fetcher_plugin: file
data_parser_plugin: simple_xml
urls: 'public://import/pim_data/pim_export_with_schema.xml'
namespaces: 'http://www.stibosystems.com/step'
item_selector: '//Product[@UserTypeID=''SKU-Set'']|//Product[@UserTypeID=''SKU'']'
fields
-
name: remote_meta_products
label: 'Meta Products'
selector: Values
ids:
remote_sku:
type: string
process:
meta_array:
plugin: meta_get_attribute_value
source: meta_title
callable: serialize
field_meta_tags/title:
plugin: sub_process
source: '@meta_array'
include_source: true
attribute: ATT22222
destination:
plugin: apex_product
bundle: product
migration_dependencies: { }
Actually my sample Xml file look like this
<Values>
<Value AttributeID="ATT22222">meta title 1</Value>
<Value AttributeID="ATT2222">sample meta desc one</Value>
</Values>
So to read the data from XML file , created the custom process plugin and I am adding the below snippet in the transform function.
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$attribute = $this->configuration['attribute'];
$metas = [];
if (!empty($value)) {
$attribute_value = $this->findAttribute($value, $attribute);
$metas['title'] = $attribute_value;
}
\Drupal::logger('migrations')->notice('<pre><code>' . print_r($metas, TRUE) . '
' );
return $metas ? serialize($metas) : [];
}
The issue here is I am able to read the ATTRIBUTE ID and its value , but the value is not stored in field_meta_tags in drupal 9.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes