microsoft / Dynamics365Commerce.Solutions

Repository for hosting the Dynamics 365 Commerce end to end sample solutions
Other
58 stars 26 forks source link

Issue in migration Retail SDK to Commerce SDK (Microsoft.Dynamics.Commerce.Runtime.Services.PricingEngine) #228

Closed Tech-Kishan closed 10 months ago

Tech-Kishan commented 11 months ago

Migration issue: Price engine deprecated in Commerce SDK.

Summary

We have done customization in Retail SDK using Price engine. Kindly find code below. now we are trying to do migration Retail sdk to Commerce SDK. as we got to know that Price engine depreciated in Commerce sdk so we are facing issue during migration.

Microsoft.Dynamics.Commerce.Runtime.Services.PricingEngine

Version and Error Info Commerce SDK : 9.44 Exception/Error Details:

Retail SDK Code:

private static async Task<GetPriceServiceResponse> CalculatePricesAsync(CalculatePricesServiceRequest request)
    {
        Changed Here
            PE.CommerceRuntimePriceAndDiscount.CalculatePrices(
            request.RequestContext,
            new PricingDataServiceManager(request.RequestContext),
            new ChannelCurrencyOperations(request.RequestContext),
            request.Transaction,
            await GetCustomerAsync(request.RequestContext, request.Transaction.CustomerId).ConfigureAwait(false),
            request.PricingCalculationMode,
            request.DateWhenActive.HasValue ? request.DateWhenActive.Value : request.RequestContext.GetNowInChannelTimeZone());
        return new GetPriceServiceResponse(request.Transaction);
    }
zhzy0077 commented 10 months ago

Hello, you can refer to the Commerce SDK sample here: https://github.com/microsoft/Dynamics365Commerce.Solutions/blob/release/9.48/src/PricingEngine/PricingSerivce/PricingService/PricingServiceSampleCustomization.cs

More specifically, the migrated code will be looking like

            private async Task<GetPriceServiceResponse> CalculatePricesAsync(CalculatePricesServiceRequest request)
            {

                // Change here
                var response = await request.RequestContext.Runtime.ExecuteNextAsync<GetPriceServiceResponse>(this, request, request.RequestContext, skipRequestTriggers: false).ConfigureAwait(false);

                return response;
            }