I'm try to make sorting by price using search_api_sorts or standard views sorting. My products have different currency USD, EUR, GBR, UAH.
Example price sorting:
- product 1 = $10
- product 2 = $20
- product 3 = 400 UAH (same as $16)
- product 4 = $500
- product 5 = $550
Instead of:
- product 1 = $10
- product 3 = 400 UAH (same as $16)
- product 2 = $20
- product 4 = $500
- product 5 = $550
When I select UAH currency for display costs of products I have a look:
- product 1 = 250 UAH
- product 2 = 500 UAH
- product 3 = 400 UAH
- product 4 = 12500 UAH
- product 5 = 13750 UAH

Comments

Dr.Osd created an issue. See original summary.

drunken monkey’s picture

Project: Search API » Commerce Core
Version: 7.x-1.21 » 7.x-1.x-dev
Component: General code » Price
Category: Bug report » Feature request

The Search API generally has no concept of a "currency". For it, those values are integers, and there's nothing to indicate it should be sorted differently. Changing the displayed currency also won't change the indexed values, which the sort is based on.

It seems you would need a processor which converts prices of indexed products to the same, configured currency, so sorting (and, e.g., filtering) will work correctly. Maybe the Drupal Commerce (I expect you're using that?) maintainers would be up for providing such a processor – let's find out. In any case, it's out of scope for the Search API.

czigor’s picture

Status: Active » Fixed

Hi Dr. Osd,
It depends on how your prices are stored. In case you're using a multivalue price field you'll probably need to write your own search api processor/views handler. Otherwise, if you have separate fields for each currency (field_price_uah, field_price_usd etc) it should work out of the box.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.