spree/spree — pull request #5798 by jschwertfeger (2014-12-18 11:45:41+00:00)
Title: Fix images and prices order on search results with taxon

Extends on #5513 which fixed the product image and prices order of products loaded through the base search class.

#5513 replaced `eager_load()` with `includes()`, in an effort to have Rails eagerly load images and prices in a separate query (due to a Rails issue outlined in rails/rails#6769). However `includes()` still resorts to joins instead of a separate query if one adds a `where()` condition on one of the included tables. Unfortunately such a condition is applied when supplying the base search class with a taxon parameter.

This fix uses `preload()` instead of `includes()` which forces Rails to always use a separate query when eagerly loading the images and prices.