Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I have 5,000 nodes with address information that I am now able to geocode by editing and saving each node.
To accelerate this process I enlisted views bulk operations to be able to save batches of nodes at one time. Unfortunately performing a batch save on any nodes causes the node's geodata to be erased.
Any thoughts on what might cause this?
Or another process for batch saving each node to more quickly geocode already existing data?
Thanks for your time.
:) Andy
Comments
Comment #1
aprice42 CreditAttribution: aprice42 commentedI am working to create a views_bulk_operations replacement script to properly save the nodes with the geocoded data. As the default VBO save function is obviously not working, and producing the result above...
To create the script I need to find the function that is being called to "save" the geocoded data.
It is my understanding that to save the node hook_nodeapi is usually called. I looked through the geocode module code, and I am not able to find a geocode_nodeapi anywhere.
Can someone please let me know what function is called to save the geocoded data?
Thanks,
Andy
Comment #2
aprice42 CreditAttribution: aprice42 commentedwith the help of Justin Miller of code sorcery, arrived at this conclusion...
using vbo to execute the following php script:
replace your_node_type with the name of your content type.
Comment #3
basvredelingThanks a L p, that snippet saved me a lot of time.
Comment #4
avr CreditAttribution: avr commentedD7 Snippet
I ran into this same issue. The "drupal_execute" function changed for D7. It works exactly the same but uses
$entity
instead of$object
anddrupal_form_submit
instead ofdrupal_execute
Comment #5
sano CreditAttribution: sano commentedHi, where do I place the script? I checked the "Execute arbitrary PHP script (views_bulk_operations_script_action)" in the "Style options" pane of my VBO view and saved the view. Then - on the view-rendered page - I chose the "Execute arbitrary PHP script" action and submitted the form (page). On the next page I entered the script - modified it first as instructed with the name of the content type being updated. I got an error:
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'nabezky_trasy' was given in /home4/stringsn/public_html/nabezky/includes/form.inc on line 377.
What am I doing wrong?
Comment #6
sano CreditAttribution: sano commentedI noticed that I have not understand what to replace in the script and missed the fact that only the bold section in the drupal_execute('your_node_type_node_form', $test_state, $test); snippet needs to be replaced with the content type name. After modifying the script the operation completes, but a new error is shown:
warning: date_format() expects parameter 1 to be DateTime, null given in sites/all/modules/date/date/date_elements.inc on line 514.
I have a CCK date field in that content type. Maybe somebody knows what is causing this new error?
Comment #7
jerdavisIt's not entirely clear to me what, if anything, is required from the module at this point - or even if this is still an active need.
Comment #8
jprstoney CreditAttribution: jprstoney commentedI have a similar issue with around 7,000 imported business that need re-geocoding for their map to re-appear. Editing a node without touching anything then re-saving works and so I ran #4 with high hopes. It ran ok, but didn't re-geocode the nodes.
Many thanks for the advice but it's back to the drawing board.
Comment #9
askibinski CreditAttribution: askibinski at Merge commentedSnippet at #4 still works if added as an arbitrary PHP snippet. Tested with addressfield 1.2, geocoder 1.2 and VBO 3.3.
Just don't forget to replace "MACHINE_NAME_CONTENT_TYPE" with your own content type machine name.
I'm just curious why the standard "Save" action which is available in VBO doesn't trigger this geocode.
Comment #10
eloivaqueHi
The code of #9 comment is work fine.
I reajusted code if you changes of all content of content types.
Comment #11
andrewmriv CreditAttribution: andrewmriv commented#4 worked for me 7 years later.
VBO, node_save(), and many other strategies do not work. I have had to manually go to the Node Edit form to click "Save" in order for the geolocation to work in 7.x-1.4.
Looping through NIDs and running
drupal_form_submit('FORM_ID', $test_state, $test);
worked for me.