I have a lot of programmatically generated nodes with the option "Generate automatic URL alias" unchecked, so i can't use the Bulk Update of the pathauto module.
How can i to bulk generate the pathauto alias for these nodes?
Edit: i use Drupal 7
Have you tried using Views Bulk Operation. All you will need to do is create a view that will list all the nodes that will meet your criteria and then assign an action 'Generate Url alias' (I haven't tried it though.)
VBO doesn't have an option to change the status of 'Generate automatic URL alias'
You could execute the following mysql query:
UPDATE `pathauto_state` SET `pathauto`=1 WHERE `entity_type` = 'node'
Or if you want to update just exact content type only:
UPDATE `pathauto_state` p, `node` n SET `pathauto` = 1 WHERE p.entity_id = n.nid and n.type = 'mycustontype'
where 'mycustomtype' is a machine name of the content type.
Or if you have drush installed:
drush sqlq "UPDATE pathauto_state SET pathauto=1 WHERE entity_type = 'node'"
After that you can bulk generate the new paths as you would normaly do on: admin/config/search/path/update_bulk
In addition to Rick B's answer, you will also need to create entries for the nodes that have never had that checked. That can be accomplished running this query:
INSERT INTO pathauto_state SELECT 'node',n.nid ,1 FROM node n WHERE n.type = 'api' AND n.nid NOT IN (SELECT entity_id FROM pathauto_state)
which can be run either using drush on directly on the database as Rick described.
For taxonomy terms, determine your term's vocabulary id (
3 in the example below) and do a similar insert:
INSERT INTO pathauto_state SELECT 'taxonomy_term', t.tid, 1 FROM taxonomy_term_data t WHERE t.vid = 3 AND t.tid NOT IN (SELECT entity_id FROM pathauto_state)
I can verify this works with Views Bulk Operations (VBO).
Just tried what Gokul N K mentioned because I ran into the same problem and I can verify it still works with actual module versions.
I had existing taxonomy terms with unchecked “Generate automatic URL alias” and I wanted to update them in bulk.
My setup below: Drupal 7 (7.34) with Views (7.x-3.8), Pathauto (7.x-1.2) & VBO (7.x-3.2). I assume the modules present / installed configured.
You need to delete the aliases for those previously created nodes before assigning them new aliases. This post explains how to do that.
For those of you that need this to be in php form for using in a module/theme/etc really quick:
<?php $update_auto_aliases = db_update('pathauto_state') ->fields(array( 'pathauto' => 1, )) ->condition('entity_type', 'node', '=') ->execute(); ?>
I think this can be done with Drupal 8 and VBO (at least it worked for me) - using the "Modify field values" action - because "Generate automatic URL alias" is just a field automatically provided for each item of content. The caveat is that you'll have to do it for each content type, but this can all be done on the same form as follows :-
I didn't get a confirmation message afterwards (which is disconcerting - probably a bug in the excellent VBO module) but it did work for me (presumably in the background batch job).