Identified in #2711099: Categorize migrations according to their type, the alter hook isn't altering. Not doing what it should is enough of an issue, marking this as major. Found this on 8.2.x.

when it's export configurations doesn't show the tags that have been added, also there the bug that doesn't add "default" value to migrations_group in migration tools, it has as it should be in the case of not having it in configuration.

Comments

edgewl2 created an issue. See original summary.

mikeryan’s picture

Project: Drupal core » Migrate Plus
Version: 8.2.x-dev » 8.x-3.x-dev
Component: migration system » API
Priority: Major » Normal
Related issues: +#2752335: Properly integrate configuration-entity-based migrations with the core plugin manager

#2711099: Categorize migrations according to their type demonstrates that hook_migration_plugins_alter() works in a pure core context - if there's an issue with it applying to migrate_plus configuration entities, that's a migrate_plus issue (which I would expect would be addressed by #2752335: Properly integrate configuration-entity-based migrations with the core plugin manager).

mikeryan’s picture

Status: Active » Closed (cannot reproduce)

migrate_plus_migration_plugins_alter() alters successfully, so there's not a broad issue with the alter hook. Unless/until there is a concrete example of this failing, closing.

司南’s picture

i got this error.
i'm using drush ms command.

versions:

drupal/core 8.6.7
drupal/migrate_plus 4.1.0
drupal/migrate_source_csv 2.2.0
drupal/migrate_tools 4.1.0

web/modules/custom/brands/artifacts/brands.csv

id,name
1,Yamaha
2,BMW

web/modules/custom/brands/config/install/migrate_plus.migration.brands_csv.yml

langcode: en
status: true
dependencies:
  enforced:
    module:
      - brands
id: brands_csv
migration_tags:
  - CSV
migration_group: null
label: 'CSV file migration of brands'
source:
  plugin: csv
  path: /artifacts/brands.csv
  header_row_count: 1
  keys:
    - id
  column_names:
    -
      id: 'Identify'
    -
      name: 'Brand Name'
process:
  tid:
    - plugin: get
      source: id
    - plugin: make_unique_entity_field
      entity_type: taxonomy_term
      field: tid
  vid:
    plugin: default_value
    default_value: brands
  name: name
destination:
  plugin: 'entity:taxonomy_term'
migration_dependencies:
  required: {  }
optional: {  }

And in web/modules/custom/brands/brands.module


/**
 * Implements hook_migration_plugins_alter().
 */
function brands_migration_plugins_alter(&$definitions) {
  $definitions['brands_csv']['source']['path'] = drupal_get_path('module', 'brands') . $definitions['brands_csv']['source']['path'];
}

when i run drush ms, then show this error:

 [error]  Could not retrieve source count from brands_csv: File path (/artifacts/brands.csv) does not exist. 
 ------------------- -------------- -------- ------- ---------- ------------- --------------- 
  Group               Migration ID   Status   Total   Imported   Unprocessed   Last Imported  
 ------------------- -------------- -------- ------- ---------- ------------- --------------- 
  Default (default)   brands_csv     Idle     N/A     0          N/A                          
 ------------------- -------------- -------- ------- ---------- ------------- --------------- 
司南’s picture

Version: 8.x-3.x-dev » 8.x-4.1
Status: Closed (cannot reproduce) » Active
heddn’s picture

Did you clear cache?

司南’s picture

Yes, I had try to clear the cache by using drupal cr and drush cr command, but it doesn't work.
Actually I also had try to reinstall my custom module several times.

司南’s picture

function brands_migration_plugins_alter(&$definitions) {
  foreach ($definitions as $key => $migration) {
    if ($migration['id'] === 'brands_csv') {
      $migration['source']['path'] = 'asdfasdf'.drupal_get_path('module', 'brands') . $migration['source']['path'];
    }
  }
}

I try to do this, but still doesn't work.

司南’s picture

Sorry, I have found my wrong after 9 months later.
The code should be:

function brands_migration_plugins_alter(&$definitions) {
  foreach ($definitions as $key => $migration) {
    if ($migration['id'] === 'brands_csv') {
      $migration['source']['path'] = 'asdfasdf'.drupal_get_path('module', 'brands') . $migration['source']['path'];
      $definitions['brands_csv'] = $migration;
    }
  }
}
司南’s picture

Status: Active » Fixed
wim leers’s picture

Category: Bug report » Support request

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.