Inhalte aufrufen

Profilbild

How can I override PriceCalculationService


Best Answer Michael Herzog , 19 January 2023 - 14:19

Hi,

 

please have a look at:

\Smartstore\src\Smartstore.Core\Catalog\Pricing\Services\Calculators\

 

There you'll find several PriceCalculators as an example how to implement your own calculator.

Documentation is following soon.

 

Regards

Go to the full post


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
4 Antworten zu diesem Thema

#1 netroskop

netroskop

    Member

  • Members
  • PunktPunkt
  • 20 Beiträge

Geschrieben: 19 January 2023 - 13:39

 
Hello, we want to override the product price in a plugin we have developed. 
 
For this we try to override the "PriceCalculationService". But we cannot do this because some methods are defined as private. 
 
For example;
 
PriceCalculationOptions.RoundingCurrency prop is internal. Instead i used "_workContext.WorkingCurrency" and this solved the problem.
 
 
but the following line
 
 context.AttributePriceAdjustments.Each(x => x.Price = ConvertAmount(x.RawPriceAdjustment, context, taxRate, false, out _).Value);
 
RawPriceAdjustment property is also defined internally
 
 
Is there an easier method?
 

 



#2 Michael Herzog

Michael Herzog

    SmartStore AG

  • Administrators
  • 3498 Beiträge

Geschrieben: 19 January 2023 - 14:19   Best Answer

Hi,

 

please have a look at:

\Smartstore\src\Smartstore.Core\Catalog\Pricing\Services\Calculators\

 

There you'll find several PriceCalculators as an example how to implement your own calculator.

Documentation is following soon.

 

Regards


  • stefanmueller und netroskop gefällt das

Michael Herzog
Smartstore AG


#3 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 19 January 2023 - 15:00

I have changed the two internal properties to "public". It is not the intention here to make things more difficult for other developers.

  • Artar, stefanmueller und netroskop gefällt das

Marcus Gesing

Smartstore AG


#4 netroskop

netroskop

    Member

  • Members
  • PunktPunkt
  • 20 Beiträge

Geschrieben: 20 January 2023 - 06:15

Hi,

 

please have a look at:

\Smartstore\src\Smartstore.Core\Catalog\Pricing\Services\Calculators\

 

There you'll find several PriceCalculators as an example how to implement your own calculator.

Documentation is following soon.

 

Regards

 

Thank you very much Michael Herzog. Creating a new Calculator is much easier and more useful.



#5 netroskop

netroskop

    Member

  • Members
  • PunktPunkt
  • 20 Beiträge

Geschrieben: 20 January 2023 - 06:18

 

I have changed the two internal properties to "public". It is not the intention here to make things more difficult for other developers.

 

 

Thank you Marcus Gesing for the development.