1

I am using the rules autotag module. It's working fine for adding new nodes. But what would I do for retagging existing nodes (approx. 40,000)?

2 Answers 2

2

According to this autotag issue on d.o, titled "How to re-tag all content":

  • Use Views Bulk Operations (VBO).
  • Create a bulk view with the 'Save post' operation
  • In the view, select the nodes you want to re-autotag and execute (which will resave all the nodes)

Note the different autotag modules:

  • autotag uses your existing taxonomies, can be used with VBO.
  • rules autotag doesn't have the UI of autotag, it's possible to use this one with VBO as well.
  • autotagging uses 3rd party services
3
  • autotagging module which you mention doesn't rely on pre-defined vocabularies. It depends on third party services. i have to tag the content with the existing vocabulary terms.
    – Jalil Khan
    Sep 2, 2014 at 12:02
  • Which 3rd party service? autotagGING uses 3rd party services, autotag doesn't AFAIK.
    – the
    Sep 2, 2014 at 13:42
  • 1
    rules autotag also worked with VBO. Thanks for sharing drupal.org/node/483174
    – Jalil Khan
    Sep 3, 2014 at 4:25
1

Just wanted to share a solution without the use of VBO but only the Rules module:

Say, you are using the Basic page with your field “MyField” for tags in the vocabulary “MyTags”

Add new component as a rule and call it “MyComponent”

Select Node as datatype, “Node” as label, “node” as machine name and keep it as a parameter

Add condition, choose Entity has field, type “node” as data selector and select field_myfield as field

Add action, choose Actionset: Autotag to terms list, type [node:body] as text for extracting terms, select MyTags as the vocabulary, switch to data selection under target list and type node:field-myfield

Now, add a new rule and call it MyRule

For an event to react on you can choose anything. I have all my nodes updated when I create a new term so I would choose After saving a new term and restrict it by selecting MyTags as vocabulary

Add action, choose Fetch entity by property, select Node as entity type and Content type as property. Because of a bug in Rules you cannot choose the content type right away but if you press Switch to data selection under Limit result count and then press Switch to the direct input mode you can now choose Basic page as value. Switch to the direct input mode for Limit result count and choose a number higher than you nodes. Hit save.

Add a loop and type entity-fetched under list and hit continue. Add an action inside the loop, choose Rule: MyComponent, type list-item as node and hit save.

Now all your nodes should be updated every time you save a term to your vocabulary.

Code to import MyRule:

{ "rules_myrule" : {
"LABEL" : "MyRule",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "taxonomy" ],
"ON" : { "taxonomy_term_insert--mytags" : { "bundle" : "mytags" } },
"DO" : [
  { "entity_query" : {
      "USING" : {
        "type" : "node",
        "property" : "type",
        "value" : "page",
        "limit" : "10000"
      },
      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "entity-fetched" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [ { "component_rules_mycomponent" : { "node" : [ "list-item" ] } } ]
    }
  }
]}}

Code to import MyComponent:

{ "rules_mycomponent" : {
"LABEL" : "MyComponent",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "node" : { "label" : "Node", "type" : "node" } },
"IF" : [
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_myfield" } }
],
"DO" : [
  { "component_rules_autotag_tag" : {
      "text" : "[node:body]",
      "vocabulary" : "mytags",
      "target_terms" : [ "node:field-myfield" ]
    }
  }
]}}

Morten

Not the answer you're looking for? Browse other questions tagged or ask your own question.