0

I have a search index View of product variations. The commerce_price field is indexed and exposed as sort option. However, when sorting by the price it appears mostly in order (Asc or Desc) but some items are not in the proper order (see screenshot)

I've tried indexing the price field as an integer, decimal, and string but it always has the same effect.

There are no additional sort items. There are not any price adjustments or custom calculations. There is no custom code affecting the Views or pricing. I've tried wiping and rebuilding the index multiple times. The View is using Better Exposed Filters.

Any ideas how I can get the products to sort by price correctly?

enter image description here

enter image description here

enter image description here

4
  • For testing something like this, I would add a view field to the display for the Product variation datasource: Price > Number to make sure it's the value I expect it to be. That should give you a good reference point to debug. Either A. the field does not have the value you expect or B. it does have the value you expect, but the sort is not working. Usually, I find that the field doesn't have the value I expect, e.g. A above.
    – sonfd
    Commented Jul 20, 2020 at 19:43
  • Are these products being discounted, and that's why they appear out of order? Commented Jul 20, 2020 at 21:07
  • Nope. There are no discounts or any price alterations at all. Just the simple commerce price field with nothing extra going on. Commented Jul 21, 2020 at 0:11
  • I added price field output to a temporary View as suggested and this is leading me on the right path. See the new screenshot. Some (a lot but not all) of the "Price>>Number (indexed field)" values are empty but all of the "Product variation datasource" has the price. Any ideas on the discrepancy of the two fields? Commented Jul 21, 2020 at 0:19

1 Answer 1

0

Resolved. Not sure exactly what is/was going on but the price sorting is now working. There was another identically named commerce price field in Views. Adding that field and removing the first one fixed the issue. I know, something unusual appears to be going on but at least the sorting is working now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.