I am looking for documentation on how to use skip_on_value but I am having trouble finding it.
The README.txt describes what it does. Same as the SkipOnValue.php file. As far as I can tell it is not used in any example. Also the issue in which this feature was introduced (much needed and thanks so far!) #2711949: Migrate Skip on Value (or non Value) there is very little usage information.

So my question is how do I use it? More people are struggling with this #2880413: Process Plugin to get default value from a source field #5 and #6

And specifically I want to ignore rows (of fields) that DON't have a certain value. There seems to be a 'not_equals' config setting, how do I set it?

Finally, if I mange to figure it out, where should an explanation go? In the readme, php file,example or create a documentation page maybe?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

firfin created an issue. See original summary.

firfin’s picture

Issue summary: View changes
heddn’s picture

Add a patch with some docs as doxygen. Similar to any of the core process plugins complete with examples.

Here's a general idea of how to use the plugin. The below config should only import blog and page content types. The other content types would be skipped.

process:
  type:
    plugin: skip_on_value
    method: row
    not_equals: true
    value:
      - blog
      - page
    source: node_types

The following would skip not the entire row, but just the value and let the rest of content migrate normally. If you want to skip the kittens value from migrating but migrate all the rest, don't use the not_equals to config option. Also note that here the method is process, so we just skip migrating that value, not the entire row as above.

process:
  field_tags:
    plugin: skip_on_value
    method: process
    value: kittens
    source: tags
heddn’s picture

BTW, #3 is untested, so it might be slightly different format, etc. But the general idea applies.

josephdpurcell’s picture

I have confirmed the examples from #3 will work.

Take note the "skip_on_value" plugin does not support specifying a source field as a value to compare against. I've opened #2916261: Skip when value matches another source value for this purpose.

elaman’s picture

For those who is using #3 and can't get it work. Use empty instead of not_empty. Tested on 8.x-4.0-beta1.

For example (migrate menu from D7 to D8):

process:
  id:
    -
      plugin: skip_on_value
      equals: true
      source: menu_name
      method: row
      value:
        - devel
        - features
    -
      plugin: static_map
      bypass: true
      source: menu_name
      map:
        main-menu: main
        management: admin
        navigation: tools
        user-menu: account
ruchi-94’s picture

Assigned: Unassigned » ruchi-94
Issue tags: +DrupalMumbaiCodeSprint

I will volunteering to upload the proper documentation for this issue.

firfin’s picture

@elaman I am guessing you mean equals instead of empty?
@ruchi-94: Good luck with your sprint, hope you have time to achieve this!

mr.baileys’s picture

Assigned: ruchi-94 » Unassigned
Category: Feature request » Task
Status: Active » Needs review
Issue tags: -DrupalMumbaiCodeSprint
FileSize
1.51 KB

First draft.

Note that I don't think the example given in #3 actually works (due to #2959775: SkipOnValue with multiple configured values and "not_equals" does not make sense.). I did include this use case in the documentation, since whitelisting values seems to be expected behavior, but the patch in #2959775: SkipOnValue with multiple configured values and "not_equals" does not make sense. should get in before this one, otherwise the second example in the plugin's documentation is incorrect.

Miri Meltzer’s picture

#6 code - Works perfectly from D6 to D8 also.
on Drupal 8.5.3

  • heddn committed 56dfb25 on 8.x-4.x authored by mr.baileys
    Issue #2902867 by mr.baileys, heddn: Documentation for skip_on_value
    
heddn’s picture

Status: Needs review » Fixed

Docs are a great improvement. Thanks for the contributions.

DuaelFr’s picture

Status: Fixed » Needs review
FileSize
949 bytes

Hi there! Thanks for this great documentation that helped me figure out how to use this plugin.
I have found a problem, though:

+++ b/src/Plugin/migrate/process/SkipOnValue.php
@@ -15,6 +15,43 @@ use Drupal\migrate\Row;
+ * - method: (optional) What to do if the input value is empty. Possible values:

This is not optional!

process:
  name: name
  to_skip_or_not_to_skip:
    plugin: skip_on_value
    source: skip_value
    not_equals: true
    value: 'skip plz'
$ drush migrate:import skip_on_value_test_migration
 [error]  The "method" key in the plugin configuration must to be set for the skip_on_value plugin. 

Here is the patch :)

  • heddn committed 88b0d14 on 8.x-4.x authored by DuaelFr
    Issue #2902867 by DuaelFr, mr.baileys, heddn: Documentation for...
heddn’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

eelkeblok’s picture

@heddn Could it be that you by accident also committed some or all code for #2902335: Empty array causes entity_lookup to fail in that last commit?