template.php hook to add variable to view
I think you want to use views hooks, not template preprocess functions. The views query will be run before the template is processed. You can find a list of views hooks here: https://api.drupal.org/api/views/views.api.php/group/views_hooks/7.x-3.x

and from that link, and alex.designworks the hook firing order:

- hook_views_pre_view 
 - hook_views_pre_build 
 - hook_views_post_build
 - hook_views_pre_execute
 - hook_views_post_execute
 - hook_views_pre_render
 - hook_views_post_render