0

Software used-> Sitecore Commerce version 9.2, VS2019

We are using Unchase OData Connection service to generate/update service proxy in VS2019. Official OData provider for VS2017 (OData v4 Client Code Generator) are not supported in VS2019. Any alternate odata proxy generation tool/extension would also help.

The below code snippet is used to pull favorite items from commerce engine using ServiceProxy.

public FavoriteModel AddFavorite(FavoriteArgumentModel favArg)
        {            
            FavoriteModel res = new FavoriteModel();
            var container = EngineConnectUtility.GetShopsContainer();
            var actionQuery = container.AddFavorite(favArg.UserId, favArg.ProductId, favArg.VariantId);
            var commerceCommand = Proxy.DoCommand<AddFavoriteCommand>(actionQuery);
            return res;
        }

The issue is AddFavorite method is not called at runtime using proxyservice.

"Method not found: 'Microsoft.OData.Client.DataServiceActionQuerySingle`1 Sitecore.Commerce.Engine.Container.AddFavorite(System.String, System.String, System.String)'." exception is thrown by ServiceProxy

Any help would really help to move forward. Thank you.

1

Sitecore internally uses Microsoft.OData.Core and client 6.19.0 and 7.5.2 versions. To use Unchase OData Connection Service you will need to update to latest version 7.6.3 which generates code that doesn't work how Sitecore calls methods with Reflection.

You still have to use VS2017 and install OData Connected Service for V1-V4 to update Connected Service to have your new commands and policies as part of metadata. So, the suggestion is to add service proxy from VS2019 and update the project from2017.

| improve this answer | |
0

It is a case of runtime version vs compiled version.

In your case, the generated proxy seems fine. In your sitecore solution, downgrade the Odata projects to 6.19 as well. That worked for me.

So here are the full steps:

  1. Generate proxy using 6.19 version of odata, using odata connected services v4
  2. Add reference to the new proxy in Sitecore project
  3. Downgrade the odata nuget packages to v 6.19 in Sitecore project (ignore dependencies)
  4. Mark these odata dlls in the project to not deploy
  5. Compile your project and deploy.

Remember the inetpub site BIN always needs odata 7.5.2. ceconnect folder inside bin needs odata v6.19

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.