Commerce

Managing Stock(inventory) in multiple warehouses

Posted on

OOTB Sitecore Commerce Engine(CE) allows you to have one inventory set for a catalog(products set). There might be situations when multiple warehouses would have the stock for a single product. In such a scenario you can easily extend CE to look for stock in multiple warehouses. When a product is added to the cart, the storefront sends a request to CE to find out if the product is available in stock. CE comes with an API api/GetBulkStockInformation which calls a command GetBulkStockInformationCommand. This command runs IGetSellableItemPipeline to get a sellable item with the availability component.     OOTB CE has PopulateItemAvailabilityComponentBlock which I replaced with PopulateItemAvailabilityComponentFromMultipleWarehousesBlock. In ConfigureSitecore.cs, I added

  While the block PopulateItemAvailabilityComponentFromMultipleWarehousesBlock is inheriting from PopulateItemAvailabilityComponentBlock. In spite of only checking the default inventory set, I am iterating over all the inventory sets to get the stock information. Note: I am calling the inventory sets as warehouses in the code. While passing the names […]

Commerce

Add to cart when there is no price on sellable item- Item is not purchasable

Posted on

There might be a situation when you don’t have any price defined on a sellable item and you still want the ability to Add To Cart. If you are not well across how pricing works in Sitecore Experience Commerce(SXC), please have a look at this article from Andrew Sutherland. In a nutshell, the pricing calculation works from Price Book to List Price. If there are price cards defined on a sellable item, that price is used but if there is no price card, ListPrice defined on a sellable item is used. If your eCommerce website has the option of Contact To Purchase, you might end up having no prices defined(nor price cards neither list price).  In such scenarios, you will get this error  while trying to add to cart Item ‘item name’ is not purchasable. At this stage, you have two options either ask your Content Author to add List Price as $0.00 which […]

Commerce

Sitecore Commerce Composer – Important tips for using this powerful business tool

Posted on

Sitecore commerce composer is a really powerful tool to extend the Commerce entities. Recently working on a project I used them quite extensively. Of course, you can still write the code to do the same but the Composer would save you a lot of time. Brief Overview:  The composer is just another business tool of Sitecore Commerce which is used to create Templates using a user-friendly UI. It’s really intuitive. You can read more about it here if you haven’t started using it. A composer template is a collection of properties. Once you create a template using composer, you can link it to different entities or item definitions to extend them.   Few things you should consider before using Composer templates in your projects. Properties Are Required: All the properties that you create would be marked as Required by Sitecore Commerce. This means the content authors would need to fill in the values of all the properties […]

Cake

Build And Package Sitecore Commerce with Cake

Posted on

Cake is really useful for building and packaging .net solutions(both net framework/core). In the world of Sitecore where Helix is the first design choice, Cake can be used to build and package the Sitecore solutions. Habitat sample has cake scripts that can be used to build Sitecore solutions if they follow Helix principles however, Habita sample uses PowerShell scripts for Sitecore Commerce. While working on a Sitecore Commerce project, I decided to write Cake build, here is a list of Tasks I created. You can access the code repository here: https://github.com/isyedakhtar/SitecoreCommerce   Default Task For Local Builds: This task is only for developer’s local machines. It does the following Clean Solution Build Solution Run Sonarq analysis(optional) Publish Commerce Engine Project Copy Published Commerce Engine Project to all Roles Transform Policies – I am using JDT transformation for policies. Replace Variables with actual values in transformed policies Bootstrap Quick-Deploy For Local Builds: This task is also for developer’s local machines. It […]

Commerce

Extending Sitecore Experience Accelerator(SXA) Repositories

Posted on

SXA modules(talking about features mainly) follow the repository pattern. Each api controller depends on a repository to call commerce roles. For example, we have a module Sitecore.Commerce.XA.Feature.Cart which takes care of cart and checkout related operations. There is a CartController which talks to AddToCartRepository for adding a product to the cart.   This repository exposes three methods

While working on a project recently, we had to implement inventory checks for certain products while adding them to the cart. AddLineItmesToCart method doesn’t check for inventory so we decided to overwrite the functionality for this method. In order to extend AddToCartRepository, we created a feature module in our project calling it MyProject.Commerce.XA.Feature.Cart. Since this module extends the Sitecore.Commerce.XA.Feature.Cart module, we added required references to our module. We only wanted to extend the functionality of AddToCartRepository so we created the ExtendedAddToCartRepository class which inherits from AddToCartRepository. And rest was simple C# code 🙂

InventoryManager was required to make the inventory […]

Commerce

Sitecore and Sitecore Commerce – Important Communication Points

Posted on

If you started working with Sitecore commerce 9.0 or later, you might have noticed there are a lot of connection points among different roles of Sitecore XP, solr, Sitecore Identity Server and Sitecore Commerce. It’s important to understand the communication points and how this communication is made secure. Sometimes we face the issues due to wrong configurations of those communication points. Since I went through a bit of pain while configuring Staging and Production environments, I thought to share how communication takes place From Sitecore XP to Commerce Engine(CE) From Commerce Engine to XP(Content Synchronization) Commerce Engine to Solr Commerce Engine Plugins to Sql Bizfx to Commerce Engine Sitecore XP to CE: The communication takes place through Commerce Eninge Connect layer. In Sitecore installation directory(at path App_Config\Include\Y.Commerce.Engine) we have Sitecore.Commerce.Engine.Connect.config which defines the communication configurations from XP to  CE. The configuration defines shopsServiceUrl which is used to send any shops related read/write requests from XP to CE for example, get catalogs […]

Commerce

Sitecore Commerce and Multiple Storefronts – Pitfalls

Posted on

Having multiple storefronts in a Sitecore commerce project is very common. We can create tenants and multiple storefronts. Similarly, we can create multiple catalogs and assign those catalogs to individual storefronts. Recently working with one of the Sitecore Commerce Projects we had to do this kind of implementation. The project started getting interesting when we came across certain requirements e.g. Braintree payment merchant credentials will be different for both Storefronts. Tax rates should be different for both Storefronts etc Now if you look at the storefront settings, we can only set these from the content explorer/commerce control panel. So looking at the documentation of Commerce Engine, we thought Policies are the way to go. Each deployed role can have different policies and behaviors, which can be specified using a specific Commerce Environment for that role. When a call is made to the Commerce Engine, the call’s header specifies an environment. This environment is used by the engine […]

Commerce

Sitecore 9.2 Installation Might Error Out While Runnings Marketing Automation Engine

Posted on

My Sitecore 9.2 installation kept on failing on the step where it tries to start the Sitecore Marketing Automation Engine service. When I looked at the logs of Marketing Automation yourpath\inetpub\wwwroot\xconnectinstancefolder\App_Data\jobs\continuous\AutomationEngine\App_Data\Logs, I found  

I thought there is something wrong with xConnect instance as xConnect is not being initialized, so browsed https://xconnect.dev.local/ which is my local instance of xConnect. I received 404 so I started looking at xConnect logs this time which said

After a bit of investigation, I came across two reasons which can cause this Either you non-self-signed certificates installed on Trusted Root CA While recent changes in security policy don’t allow this Or you have too many signed certificates installed on Trusted Root CA One of these can lead you to failure of xConnect service. I came across a useful power shell command which lists down non-self signed certificates being installed on trusted Trusted Root CA. Due to recent change in […]

Commerce

Debugging Sitecore Commerce 9.2 Engine Using Customer.Sample.Solution

Posted on

Sitecore Commerce(SXC) Engine is an extensible framework to develop new or extend existing commerce services. SXC has this concept of Plugins which can be created to customize it. A plugin is nothing but an atomic and self-maintained module of software which contains Pipelines, blocks and policies. I setup Sitecore Commerce 9.2 recently and in order to start development using Visual Studio, I had to set up a new VS solution. SXC makes it easier for you as it comes with a sample solution which lives inside Commerce Engine SDK . This sample is called Customer.Sample.Solution. This solution can be used as a boilerplate code to kick off the development. When I started setting up my Visual Studio, I came across a few issues. Purpose of this post is to make it easier for anyone out there facing those problems of having questions How To. The first step would be to locate the sample solution. During […]

C#

Transient fault handling in Sitecore Commerce

Posted on

Transient fault handling can be cumbersome and lead developers to write repetitive code. There could be many situations when you want your code to be retried in case of failures/exceptions etc. While working with a few external system integrations, we had to implement a retry mechanism for certain transactional requests. Payment integrations are one of the examples that I am using here. Polly is a library that allows developers to express resilience and transient fault handling policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. Almost all the payment providers we integrated to Sitecore Commerce project e.g. Braintree/DiectBank/Openpay recommend to retry the transactional requests in case of timeouts or internet issues. For example when we request Braintree payment gateway to settle the payment if the request times out you have to retry the same request 3 times before you treat it as a failure. Since the retry could be handled […]