• Not Answered

TranslateCartToEntity

Hi, in a Sitecore 9.1 installation, I get an exception:

Unable to cast object of type 'Sitecore.Commerce.Entities.Prices.Total' to type 'Sitecore.Commerce.Engine.Connect.Entities.CommerceTotal'.

It seems this exception originates in a class called Sitecore.Commerce.Engine.Connect.Pipelines.Carts.TranslateCartToEntity, method TranslateTotals, when it calls:

 CommerceTotal commerceTotal = this.EntityFactory.Create<CommerceTotal>("Total");

There is probably some sort of configuration error in my setup, but where should I start looking?

Thanks.

1 Reply

  • Yes - I found out that some config for <commerce.Entities> was missing on my CD site where the error occurred. The config file "Sitecore.Commerce.Prices.config" defined:

    <Total type="Sitecore.Commerce.Entities.Prices.Total, Sitecore.Commerce.Connect.Core" />

    But what was missing was the config file "Sitecore.Commerce.Engine.Connectors.Carts.config", which patched this to a different type:

    <Total>  <patch:attribute name="type">Sitecore.Commerce.Engine.Connect.Entities.CommerceTotal, Sitecore.Commerce.Engine.Connect</patch:attribute></Total>