Developer forum

Forum » Ecommerce - Standard features » Sort by price from price matrix

Sort by price from price matrix

Eva Sommer
Reply

Hi,

We have run into an issue with the price sorting. All product prices are 0,- and we only use prices from the price matrix. The pricematrix for a product can contain prices for one or for two different shops. We have products with and without variants.

I followed the guide from the link below, and added the sorting for the price for one of the shops, but this has not solved the issue.
https://doc.dynamicweb.com/forum/ecommerce-standard-features/ecommerce-standard-features/sort-by-price-behavior-in-rapido

Price added by me in query

Do I need to add something to the index to have these prices avaliable? Or can it maybe have something to do with our master/variant query setup ?

Our priceId is a bit special, but I am not sure if the price selected in the sort, just looks for PriceProductId, and therefor not the issue
 

PriceId PriceProductId
01047661DKKSHOP13 0104766
 
 
Thank you
- Eva Sommer

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

There is a setting on the ProductIndexBuilder, SkipPrices, that of course cannot be true. Default it is not.

And if you can choose the field, it is there.

But you are sorting by scor, price - meaning score will be first - so you need to remove score or sort by price, score instead.

BR Nicolai

 
Eva Sommer
Reply

Hi again,

I verified that SkipPrices is false.

I removed the scor and tried again, only with price sorting, but still with no luck. It just shows the same order 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Ok, this screenshot is different - that is from Rapido - it will put a index fieldname into the URL which is used to sort by. You have to change that fieldname to be the one you have in the index or move the data from the field with the right data to the field that is used for sorting. 

makes sense?

BR Nicolai

 
Eva Sommer
Reply

Hi again,

I am not entirely sure if I have done what you meant, or correctly. But I added Price to the index where it should get the price from the prices, not product price. But with no sorting luck

?SortBy=Price&SortOrder=DESC

- Eva Sommer

 
Eva Sommer
Reply

Ah I see, ProductPrice|DKK|DK it appears both to 0 in the index. What is the easiest way to go around getting prices from the price matrix in the index, so we can sort by them?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Eva

If you have a price in DKK in the pricematrix, this should give you the price. How does the prices look like for this product?

 
Eva Sommer
Reply

An example of one of the prices on the shop:

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

If you add a shop on the price, the price will not be indexed. In that case the product would have multiple prices for the same product/country/currency combination which is not possible. 

So only prices that differ on country and currency is indexed.

The core problem is that the product can have many prices - one for each country, currency and shop resulting in so many fields on the index that it could potentially break.

In this case, do you have different prices for the same product in different shops?

BR Nicolai

 
Eva Sommer
Reply

Yes, the pricematrix for a product can contain prices for one or for two different shops and also for different usergroups. 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

yes - So what would be the price in that field for DKK/DK if you have multiple prices? So you would have to add a base price for the currency/country only to sort by.

 
Eva Sommer
Reply

Thank you for the clarification. We have decided to go with extending the index. I was wondering though, if I can get a hold of the index builder and via that determine what shop?

This returns null:
        public override void ExtendDocument(IndexDocument indexDocument)
        {
            var indexBuilder = IndexBuilder;
        }

Shop on productIndexBuilder:

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

On the indexBuilder instance you have a DefaultSettings that will contain a key, "ShopsToIndex" that hold that information.

BR Nicolai

 
Eva Sommer
Reply

As mentioned above the indexBuilder is null. Is there some documentation on how to get the instance, that I cannot find? :)

Thanks

Eva Sommer

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Ah - a little too fast.

How does your class definition look like

 
Eva Sommer
Reply

I have taken out the custom code. Basically like this    

public class ProductIndexExtender : IndexBuilderExtenderBase<ProductIndexBuilder>
    {
        public override void ExtendDocument(IndexDocument indexDocument)
        {
            var indexBuilder = IndexBuilder;
        }
    }

Found this post, but there is no solution suggested there

http://doc.dynamicweb.com/forum/cms-standard-features/cms-standard-features/distinguish-index-on-indexbuilderextender

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Eva

I have created bug #9922 that should ensure the indexbuilder property has a value. A fix is created and send for test and review. Will be released Dynamicweb.Ecommerce 1.14.* when completed.

BR Nicolai

Votes for this answer: 1
 
Eva Sommer
Reply

Great, thank you. 

In the mean time, is there another way to check what index it is, so we do not trigger the functionality for indexes where it is not releavant, fx PIM index

 

- Eva Sommer

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Eva

The bugfix #9922 has been released in Dynamicweb version 9.14.2

You can get this from the download section https://doc.dynamicweb.dk/downloads/dynamicweb-9

Kind Regards
Care Support
Kristian Kirkholt

 

You must be logged in to post in the forum