Posts

Showing posts with the label Episerver Commerce

How your site appears in google search results

Image
Search engines now look deep into site contents and try to understand more about your site e.g. Google uses structure data to understand more about the content on your page. By providing structured data we not only can get the benefit of special features like rich snippets but also our site will be eligible to appear in graphic search results. By providing structured data you can outstand your site presence in the google search results and in result increase in clickthrough. While searching keyword 'eCommerce' (from the UK, 5th of May 2020) I get the following results. These are the highlights of the page Featured snippet Related Images Article Books People also searched for FAQ and the rest of the search results. Google supports structured data in the following formats  JSON-LD  (recommended, use this format whenever possible),  Microdata , and  RDFa . Google also uses  schema.org vocabulary, but for definitive, google search behaviors, r...

Get Specific Elements Blocks from EPiServer Forms

A small extension to get the specific form elements block with all properties rather relying on   FriendlyNameInfo  with the limited set of properties. EPi Form Extensions Gist Example: Custom form element block: public   class   HiddenExternalValueElementBlock  :  HiddenElementBlockBase {     [ Display (Name =  "Enable if its a special campaign" )]      public   virtual   bool  MySpecialCampaign {  get ;  set ; }     [ Display (Name =  "Propperty 1" )]      public   virtual   bool  Property1 {  get ;  set ; }     [ Display (Name =  "Property 2" )]      public   virtual   bool  Property2 {  get ;  set ; } } Extension Methods: using  EPiServer.Core; using  EPiServer.F...

Azure based architecture for serving EPiServer CMS As Content Hub

Image
This architecture uses the Azure API Management to provide access to content from EPiServer for different channels. Contents are exposed via headless API and other Custom written APIs. Editors and admins will have secure access to EPIServer CMS. API Management is used to publish APIs to external, partner and channels, securely and at scale. Application Insights is used to detect issues, diagnose crashes and track usages. AAD - Azure Active Directory is used for secure, enterprise-grade authentication. Traffic Manager is used to determining which web app is geographically best placed to handle each request, and will be used to obtain zero downtime.  A CDN - content delivery network serves static content, such as images, script, and CSS for different channels. Azure SQL DB/Redis Cache/Azure Blob Storage to server data about the site in a high performance and highly scalable way References: Episerver headless white paper Cont...

Serialize IContent to use in Angular like front technologies

(A self note) A generic service to convert IContent into an Expando Object , ExpandoObject  can be converted into JSON to use in Angular/React components. Find the code gist  https://gist.github.com/khurramkhang/e8d4b9ef093fe30610be986efa352744 Limitations: not supporting multilingual not preparing friendly urls

Few best practises while working with orders

Validate the status of line item (at required stage in sale flow) to make sure the product is active, within the valid date range, and that the catalog entry is available in the current market. Validate the status of line item (at required stage in sale flow) to make sure business does not lose money. It is important to add coupons to the IOrderForm before running apply discounts(cart.ApplyDiscount method) Avoid saving carts unnecessarily and repeatedly. You should avoid casting back and forth between concrete Order classes (OrderGroup, OrderForm, etc.) and the new abstraction interfaces (IOrderGroup, IOrderForm, etc.). For example, from the time you load the cart or purchase order until you save it, only use one API. While this is not always possible, doing it whenever possible helps avoid hidden problems when casting. Do not use Math.Round() for rounding. The following methods return a value with the correct number of decimals, which is determined by the input currency. - C...

How to render SVG in edit mode

Self note: SVG is a smart media format that enables us to use same image in different sizes without compromising on quality and performance. EPiServer supports SVGs but images will not display in editor mode while using the IMG tag, as media urls are updated with version details. e.g. "globalassets/160-835st_bilok_2_screw_straight8mm_x_35mm.svg" will change as  "/episerver/CMS/Content/globalassets/en/160-835st_bilok_2_screw_straight8mm_x_35mm.svg,,1823?epieditmode=False&visitorgroupsByID=undefined". EpiServer will resolve urls for media in this way in Edit and Preview mode. In result svg will not be shown in editor mode. To display the SVG in edit mode, we will be required to resolve url in Default mode, this can be done by calling an overload of the GetUrl-method of the UrlResolver: UrlResolver.Current.GetUrl(svgContent, language, new VirtualPathArguments () { ContextMode = ContextMode.Default })

POC custom pricing provider works

In most ecommerce websites, prices comes from some third system and we import the prices into EPiServer Commerce along with products and variants data, but this is not the case all the time. In some scenarios pricing are quite complex and have to decide at run time or require to retrieve from some web services. A custom pricing provider can be built to support these kind of scenarios. we are require to implement IPriceService for read only prices and IPriceDetailService for Editing prices. We will be require to register these service in structure map e.g. services.AddSingleton< IPriceService, CustomPriceService >(); Find the POC on GIST

Custom Price Placed Processor

We need to implement IPlacedPriceProcessor interface to get the currently-placed price for an line item if business have additional pricing rules outside of what is implemented in out of the box pricing provider. Here is an example implementation. We wre required to inject custom classes at startup via structuremap.

Custom Line Item Validator

Amazon offers AddOn products that can be bough with some other product only. Addon products must be removed from basket if added without the parent product. This type of validation can be done easily by implementing ILineItemValidotr interface. You can find a test implementation of custom Line Item Validator on Git. You will require to register new custom validation class implicitly into your container. It will be helpful if in future versions a generic type can be used rather ValidationIssue Enum in Validate method.

Blocks for EPiServer Commerce Catalog Nodes

Can we use Blocks with Catalog nodes? In theory Yes, what can stop you. We had a requirement when CMS editor can add a Carousel Block to Catalog Nodes. But Block Gadget was not available in CMS Catalog Edit Mode. Only available gadgets were Catalog, Media, Latest and Versions. From architecture point of view I was convinced that we can add ContentArea for Catalog Nodes and Blocks can be reused for Catalog Nodes also. I googled the issue and find an answer by Linus. Its simple I want to keep solution as a self note. Add the following section under your <episerver.shell> section in web.config and the blocks gadget should appear for the commerce view (given that you have not customized your view):<viewManager> <views> <add name="/episerver/commerce/catalog"> <settings> <add name="AddSharedBlocks" transformationType="Add" definitionName="EPiServer.Cms.Shell.UI.Components.SharedBlocksComponent" plugInA...

Assets and media in EpiServer Commerce 7.5

Asset management in Commerce By default the new content-based asset management system with the blob provider model  is used for adding assets to the catalog nodes and entries when manging catalogs. All files are stored in the same location as the EPiServer CMS files, providing a more unified user experience. In a Commerce installation, products and product variants from the product catalog can be accessed from the Catalogs gadget in the Assets pane, with general support for drag and drop of content items into CMS pages and blocks. The integration is done using content type classes EPiServer.Commerce.Catalog, EPiServer.Commerce.Catalog.ContentTypes and EPiServer.Commerce.Catalog.Provider. Configuration of asset management systemThe legacy Asset Management system for Commerce Manager is still available in EPiServer Commerce, but by default the new asset management system is configured to be used. A notification message with this information is displayed. The configuration setti...

Installing EpiServer Community on a commerce site

Installing EPiServer relate on an EPiServer CMS 7 site working with EPiServer Commerce can be a challenge, This post can be helpful for those who are trying to do this or facing issue in installing other EPiServer products. Technologies under discussion are EPiServer CMS 7.1, EPiServer Commerce 1 R3 EPiServer Relate+ 7 Issue: Installing Commerce and Relate (Community) is a no go http://world.episerver.com/Support/Bug-list-beta/bug/95414/ Issue details: An unhandled error has occured:  The argument is null or empty. Supply an argument that is not null or empty and  then try the command again. When executing At C:\Program Files (x86)\EPiServer\CommonFramework\7.0.844.1\Install\System Sc  ripts\Upgrade Site.ps1:93 char:17 + -SqlServerName <<<< $properties.DatabaseServerName `  An unhandled error has occured:  The argument is null or empty. Supply an argument that is not null or empty and  then try the command again. When exec...

Unwanted Lucene Search Results in EpiServer Commerce R2

Issue: User was getting unexpected search results for products, e.g. with a search key word ‘Sate’ he was getting same result as for ‘Site’. Although for most of the clients they will happy with these results but this particular client was unhappy with this result due to their business requirements. We do not have any word like ‘Sate’ in our Database or in Index file for Lucene. Clearly it was Fuzzy search that was causing this although in code we have set FuzzySearch = false; Reason: // Perform Lucene search SearchResults results = searchFilterHelper.SearchEntries(criteria) as SearchResults ; In the Mediachase.Commerce.Website, Version=5.2.243.2, SearchFilterHelper's SearchEntries() method, below: public virtual ISearchResults SearchEntries(CatalogEntrySearchCriteria criteria) {  try  {   _Results = Manager.Search(criteria);  }  catch (SystemException)  {   if (HttpContext.Current.IsDebuggingEnabled)    throw; ...