A little bit to our setup:
We have search_api + search_api_solr + facetapi + vbo running. Everything works as expected and filtering like mad works really well. I never noticed that, but I now had the requirement to filter data down via facets and for the remaining part I used VBO to select all items (ALL items (also the paginated ones .. this might be important)) and run an export to CSV from that filtered data.
The off thing was, that VBO also enqueued ALL 27000 items instead of the 345 items I had filtered. I do know that the VBO works that way, that it saves all information it needs to rebuild the view accordingly to build up a Queue which in step 2 is then processed in what ever it needs.
It took me a few hours to find the cause, because in the first execution (right after clicking submit) VBO gets the correct count of items from the view. So exposed_input and so forth work. This might be the case, because the _GET is still filled with all the f[0] arguments (Solr kind of).
But on first run of views_bulk_operations_adjust_selection($view_info, $queue_name, $operation, $options, &$context) when all data is put back into the view to work as expected it returns total_rows of all elements in my case 27000.
So why am I posting this here? Well I tracked it down to search_api_facetapi_search_api_query_alter($query) which calls for an adapter which the facetapi returns. That Adapter is the FacetapiAdapter, which in $this->initUrlProcessor(); calls $params = $this->urlProcessor->fetchParams(); and this is a direct return of $_GET. because I am in a batch $_GET does not contains any facet parameters, it contains q=batch; op=do .. i.e. batch api stuff.
At this point I have no clue how to proceed. Because I am in a batch process and the $view->exposed_input is there, but the facetapi uses not that, it uses $_GET which is a fail at that point. Maybe someone with greater knowledge can provide some advice for that scenario.
/**
* Implements FacetapiUrlProcessor::fetchParams().
*
* Use $_GET as the source for facet data.
*/
public function fetchParams() {
return $_GET;
}
The attached image shows a point of debug which might be helpfull. The second screenshot is just another point in the callstact to show that actually the $view itself gets correctly filled with the exposed_input data.
My guess is that the facet UrlProcesser is wrong at that point.
I'll also point this issue on VBO and search_api to draw attention if that is not the fault of facetapi.
| Comment | File | Size | Author |
|---|---|---|---|
| vbo_facet_search_api_002.png | 181.16 KB | ro-no-lo | |
| vbo_facet_search_api.png | 153.62 KB | ro-no-lo |
Comments
Comment #0.0
ro-no-lo commentedtypos
Comment #1
ro-no-lo commentedI added a hack for our needs, which will ofc break every time we update the VBO or facetapi modules. I noticed that you can provide your own UrlProcessor somehow. Because both modules are not my field of expertise, I did a hack which works in our case. So anyone need to fix that too, here my hack:
views_bulk_operations/views_bulk_operations.module#821
facetapi/plugins/facetapi/adapter.inc#233
Comment #2
ro-no-lo commented// removed
Comment #3
cpliakas commentedHi ronan.orb,
Thanks for the detailed debugging. Although Facet API uses the $_GET variable by default, there is nothing stopping you from instantiating adapter via facetapi_adapter_load() and passing
$view_info['exposed_input']to the FacetapiAdapter::setParams() method. This is method allows developers to alter the variables that contain the facet information using whatever data they want. This should allow you to use the facet data passed by the VBO module without having to hack the module.I am re-marking this as a support request, because my feeling is that the API is flexible enough to support edge cases like the one posted above. Please feel free to switch this back to a bug report if the technique doesn't work.
Hope this helps,
Chris
Comment #4
firfin commentedDid cpliakas suggestion work for you ronan?
Would you care to comment / explain for posterity? ;-)
Comment #5
ro-no-lo commented@firfin: I do not work at that company anymore where we had that setup, therefore I cannot provide useful feedback.
Comment #5.0
ro-no-lo commentedadded code of interest
Comment #6
roeldl commentedA quick workaround without hacking facetapi or VBO is adding the GET params in hook_batch_alter to the url options of the batch.