0

I'm working on an SXA Project with to different code base one with SXA Commerce and other with SXA without commerce integration. The commerce site is gone to production before 4 months and we started developing a non-commerce SXA site that will be hosted on the same webroot of Commerce site and same Sitecore content tree.

We've 2 API calls in non-commerce site tp retrieve the products from Sitecore. These API calls were working fine till the UAT environment and on Production CM/CD, it doesn't and getting the below exception while we hit the API.

enter image description here

Since it is an environmental issue I've started my investigation by comparing the Config files, dll, Pipeline orders using Showconfig, and cross verifying all the files moved from UAT to Prod. Everything seems normal.

For API we've used the Register route and Initialized it by using Initialize pipeline. I've attached the code for your reference.

  1. Register Routes
    public class RegisterHttpRoutes
    {
        public void Process(PipelineArgs args)
        {
            RouteTable.Routes.MapRoute("ProductAccessoriesControllerApi", "api/sitecore/ProductAccessories/{action}", new { Controller = "ProductAccessories" });
        }
    }
  1. Controller
    public class ProductAccessoriesConroller : SitecoreController
    {
        private readonly IMvcContext _mvcContext;
        private readonly IProductAccessoriesRepositories _productAccessoriesRepositories;

        public ProductAccessoriesConroller(IMvcContext mvcContext, IProductAccessoriesRepositories productAccessoriesRepositories)
        {
            _mvcContext = mvcContext;
            _productAccessoriesRepositories = productAccessoriesRepositories;
        }

        public JsonResult GetAccessoriesForProducts(string pid, string pageNum, string numberOfResultsPerPage)
        {
            ProductAccessoriesJsonResult jsonOutPutResult = _productAccessoriesRepositories.GetProductAccessoriesJson(pid, pageNum, numberOfResultsPerPage);
            return Json(jsonOutPutResult);
        }
    }

  1. Patch File
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="MyAssembly.Feature.PDP.RegisterHttpRoutes, MyAssembly.Feature.PDP" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
      </initialize>
    </pipelines>
  </sitecore>
</configuration>

Kindly let me know if I'm missing anything.

Your Answer

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

Browse other questions tagged or ask your own question.