-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix duplicate variants on product page
This fixes issue #1654. The default pricing options class has a `search_arguments` which adds `nil` as a matching possibility for the price's country field (in order to accomodate for the fallback price). In Spree::Variant.with_prices, Spree::Price.where(search_arguments) is merged into a Variant query. This results in duplicate variants being returned. From the standard product page, `Spree::Variant.with_prices` is called by `Spree::Product#variants_and_option_values_for(current_pricing_options)`. This replaces the 'merge' call in Spree::Variant.with_prices with an SQL EXISTS subquery. There are quirks with ActiveRecord here: `.where(pricing_options.search_arguments)` - which translates to `.where(currency: "EUR", country_iso: ["FR", nil])` and does pretty much the same as the expression in this commit. However, that one just simply does not work in this context, which is why I took the decision to write the SQL by hand.
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters