Lucene search returns incorrect price

  1. In Products => PriceLists (I have set to excl vat)
  2. In Channel settings => Channel (I have display incl vat)
  3. Default vat is 25%
  4. No tax item is added to product
  5. For a Product the price is set 2060:- (exl VAT)

Price for the product on page will display correctly 2575:-

When using Litium ProductSearchService it will hit

var priceTagName = _requestModelAccessor.RequestModel.Cart.IncludeVAT ? "-price-incl_vat" : "-price"; // True

var priceTagName = -price-incl_vat
So far so good.

But here comes the interesting part:

var searchResult = searchResponse.Hits
    .Select(hit =>
    {
         var priceTags = hit.Tags
             .Where(x => x.Name.EndsWith(priceTagName, StringComparison.OrdinalIgnoreCase))
             .Select(x => x.OriginalValue)
             .Cast<decimal>()
             .DefaultIfEmpty(decimal.MinusOne)
             .Min();
         return new SortableSearchHit(hit) { Price = priceTags };
    })
   .ToList();

For the exact product above it will return:
price-incl_vat:000000000000000000002060

Am I assuming wrong here to expect price with VAT (2575)?

  • I have tried to rebuild product index from BO.
  • Double checked the price in BO (shows 2060 excl VAT)
  • Double checked the price in Products.PriceListItem table (shows 2060 excl VAT)

Litium version: 7.2.3

It sounds like you’re encountering this bug:
Price including VAT Lucene tag not set correctly if base product has no tax class link

This was resolved in Litium 7.3.

Does it work if you add an actual tax class to the base product?

I’l test. Could have sworn that i was searching through the bug lists before posting.
One additional question here. Will it also contain products campaign prices or do we need own implementation?

In general, campaign prices are not indexed as standard. Campaign prices are calculated as needed.

There’s a scenario where it is though: if you’re using the fixed price action and the belongs-to-a-group condition. There’s a CampaignIndexingProviderPreProcessor in the Accelerator.

Reason for this is when we example want to search for products between x and y and then also sort the output (lowest price for example)

For this to work we would need as I see it index the campaign price using the PreProcessor and fetch on both and and then sort.

The challenge is if you’re using campaigns with conditions like order total exceeding X or similar. But if it’s an always-on price reduction with no conditions, it should work.

Just wanted to add that there’s a bug report about price sorting not taking campaign prices into account, so it’s on the product teams radar as well: https://docs.litium.com/support/bugs/bug_details?id=49201

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.