Customer specific product prices


#1

I need to implement customer specific product prices.
For this I have created an importer that associates customers with products and prices.

Now the question is where is the extension point to use this customer specific price?
Bonus points if there is a way to deactivate purchasing of a product if the customer has no specific price.


#2

Hi Lukas,

to implement customer specific prices you need to do two things:

(1) Add these customer/price relation to Redis.
The product prices are placed in the entry of the concrete product and then part of the StorageProductTransfer. My recommendation is to implement a new collector that creates one entry per product/customer pair and to overwrite the price in the StorageProductTransfer. This can be done in the ProductClient after the call of getProductConcreteById(). To get the current user you can provide the the SessionClient from the factory.

(2) Use the price in cart calculation.
To change the used price of an item have a look into CartDependencyProvider::getExpanderPlugins(). You need to implement your own CartItemPricePlugin and use the correct price. The plugin gets the QuoteTransfer as input parameter and you’ll need to add the customer ID here.

In case you need help, please contact me.

The most tricky part is the search. I don’t know a good strategy to implement customer specific prices with Elasticsearch. So the most pragmatic solution is to keep the default price there and to replace the shown prices in Yves with the ones from Redis. Of course sorting and filtering will be affected, but maybe that’s fair enough for now.


#3

yeah … 1) was my plan … but 2) was the piece I was missing … and yeah price sorting in search will be hard to achieve with customer prices.

any advice on hiding products (as much as possible) that the customer does not have a custom price for?


#4

Hiding from search results is tricky. Maybe you just filter out the products from the results after the search was executed?


#5

Just an idea: I don’t know how many products you need to deal with, but alternatively you could also import products multiple times to Elasticsearch with the customer ID(s) and the associated price. Once you have this, it’s pretty straightforward to filter the catalog for each customer. Filtering and sorting will use the custom price this way also.

Edit: handling document IDs will be problematic though.


#6

got it to work …
since the prices are actually just fixed discounts (well by category), the ordering of the prices should be ok by simply fetching them at display time. I have done the necessary changes to the CategoryClient as well.

furthermore I adjusted availability to false in case the customer has no price for the given product.

hurray!