Posts

Showing posts with the label Hybris

Flexible Search in SAP Commerce [Hybris]

In this article, I have explained in details about Flexible Search in SAP Commerce Cloud [SAP Hybris] with some real time examples. What is Flexible Search in SAP Hybris? Flexible Search is a Hybris built-in query langua g e based on SQL syntax and it enables us to search records from the database using item types. In flexible search queries we never use database table names directly, instead we use item types which are mapped to corresponding tables in the items.xml file. In flexible search query we must specify item type code and its attributes in curly braces:            e.g.  Select {code}, {name} from {Product}. When we execute the flexible search query in Hybris, it has 2 phases: Pre-parsing phase:                                                                        ...

items.xml in SAP Commerce [Hybris]

The items.xml file specifies types of an extension for defining the data model . By editing the items.xml file, you can define new types or extend existing types. In addition, you can define, override, and extend attributes of the types. Location of the items.xml file: The items.xml is located in the resources directory of an extension. The items.xml files are prefixed with the name of their respective extension in the form of extension name-items.xml. For example: For the core extension, the file will be core-items.xml . For the catalog extension, the file will be catalog-items.xml . Basic structure of the items.xml file: The items.xml defines the types for an extension in XML format and the basic structure is as follows: <items   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"               xsi:noNamespaceSchemaLocation="items.xsd">           ...

Type System in SAP Commerce [Hybris]

In this article, I have explained in details about what is a Type System in SAP Commerce [Hybris] and how the data can be organized in the Hybris system. Type System in SAP Commerce is a data modeling framework . It defines the structure and organization of data within the platform. In SAP Commerce data can be organized in the form of types , for example product information, customer information, address information, cart information and order information etc. A type is a template for objects and every object stored in a platform is a type instance. Types can be defined in an items.xml file using following aspects: the deployment : It defines the database table where objects stored. attributes : Manage and store data for the object. the java class of the object. In SAP Commerce, Type is a blueprint of an Item and Item is an instance of a Type . Types can inherit from other types, allowing for a hierarchical organization of data. Attributes define the properties of a type. They can ...

Differences between Extension and AddOn in SAP Hybris

In this article, I have explained differences between Extension and AddOn in details in SAP Commerce [Hybris] and also described when to use Extensions and when to use AddOn's. An Extension is a self-contained module that adds or modifies functionality in SAP Commerce.   An Extension generally represents a larger functionality and it contains business logic, type definitions, back-office configurations and other configuration files like xml, properties and etc, whereas AddOns are used to extend the functionality of SAP Commerce Accelerator[storefront] without modifying the core code base. AddOns are plugin kind of extension, you can easily remove your AddOns without refactoring the code of your Accelerator extension. Extension can work independently or extend the another extension whereas AddOn always depends on an existing extension (e.g. acceleratorstorefront). Extensions are used for business logic whereas AddOns are mostly used for Frontend/UI customization.     ...

AddOns in SAP Commerce [Hybris]

In this article, I explain in details about the AddOns in SAP Commerce and demonstrate how to create our own custom AddOn using ant extgen command based on yaddon template.  AddOns are used to extend the functionality of SAP Commerce Accelerator[storefront] without modifying the core code base. AddOn is a type of extension that allow you to add front-end related files such as JSP, HTML, CSS and JavaScript files without modifying the storefront front-end files directly. AddOns will never alter the core business logic rather it just enhances the existing storefront behaviour. AddOns often refers to plug and play kind of extensions and anytime you can install or uninstall from the storefront without effecting core business functionality. Generally, AddOns contains front-end related logic whereas extensions contain business logic. Creating a custom AddOn:           We can use same ant extgen command to create your own custom AddOn and need to provid...

Extensions in SAP Commerce [Hybris]

Image
In this article, I will explain in details about the extensions in SAP Commerce and demonstrate how to create our own custom extension using ant extgen command. SAP Commerce has a modular architecture, where new business logic is developed in a separate, function specific modules called extensions. Extension in SAP Commerce is very similar to project in Java. An extension contains business logic, type definitions, back-office configurations and some configuration files like xml, properties and etc. SAP Commerce ships with a number of template extensions and we can use ant  extgen for generating new extensions based on these template extensions. Every extension in Hybris contains one important file called extensioninfo.xml file which contains information about extension name, extension module and its dependencies.  To make any custom as template extension using below meta tag: <meta key=’extgen-template-extension’ value=’true’/> Create a New Extension: Creating a new e...

Initialization VS Update in SAP Commerce [Hybris]

Image
In this article, I will explain the detailed differences between System Initialization and Update process. SAP Commerce includes a built-in initialization process that first removes all existing database content, performs several required steps in the background, and then leaves the system in a predefined state. In addition, an Update only applies the requested changes and deploys the most recent changes to the database. In the following discussion, I will explain the detailed differences between System Initialization and System Update. Initialization: When you perform system initialization, the following actions are carried out: It removes all the existing data in the DB. It drops all the existing schemas and tables [i.e. existing type definitions defined in items.xml file] from the DB. It will recreate the schemas and tables in DB. It reloads the data into the database. All the data available in DB will be lost after initialization. We can Initialize SAP Commerce either from command ...

Ant all VS Ant clean all commands in SAP Commerce [Hybris]

Image
In this article, I will explain the difference between most commonly used Ant build commands like ant all & ant clean all . SAP Hybris uses Apache Ant build framework to build the extensions or modules in the Hybris framework.  There are several ant targets available to build the hybris framework like ant all, ant clean and ant clean all. We can find list of available ant targets by using ant -p command as shown below: Note: before running any ant command we must set ant environment from platform folder.             C:\Trainings\CX2211\hybris\bin\platform> setantenv.bat Ant clean all: When we run the ant clean all command from the platform folder, it does the following things: First it will check whether all folders like bin, config, data, log, roles, temp folders are available inside hybris folder or not. If the folder structure is not available then it creates else it won't create any folder structure.  It deletes all existing gen...

Install & Customize SAP Commerce [Hybris] B2C Site using ant modulegen

Image
In this article I am going to demonstrate, how to install and customize our own SAP Commerce [Hybris] B2C site using modulegen command. ant modulegen command can be used to create the module, which contains set of extensions based on the module template we selected. Step1: Download SAP Hybris / SAP Commerce suite from SAP Portal and extract in a folder as shown below: Step2: Install SAP Commerce using installer recipe [cx]:                Before installing recipe, we can see only bin folder under hybris as show below:                Now go to the installer path and install using cx recipe:                Syntax:  installer.bat -r recipe_name local_property:initialpassword.admin=PASSWORD                                install.bat -r cx -A local_property:initial...

Installing SAP Commerce Cloud [Hybris] using Installer Recipe

Image
In this article I am demonstrating, how to install SAP Commerce[Hybris] using installer recipe. After successful installation we can verify Hybris provided Out of The Box eCommerce sites like Electronics, Apparel UK and Powertools. Here, I am using SAP Commerce Cloud latest version 2211. Step1: Download SAP Commerce[Hybris] suite from SAP Portal and extract in a folder as shown below: Step2: Install SAP Commerce using installer recipe [cx]: Before installing recipe, we can see only bin folder under hybris as show below: Now go to the installer path and install using cx recipe: Syntax : installer.bat -r recipe_name local_property:initialpassword.admin=PASSWORD                 install.bat -r cx -A local_property:initialpassword.admin=nimda Note: This recipe command will add required extensions to the localextensions.xml file based on the recipe name & now we can see other folders in hybris folder: We can also see localextensions.xml file generat...

Introduction to SAP Hybris / SAP Commerce Cloud

SAP Commerce Cloud [formerly SAP Hybris] is an eCommerce platform and PCM Software also known as eCommerce Solution using which we can develop eCommerce websites like Amazon, Flipkart, Shopper Stop and Ajio etc. Here PCM stands for Product & Content Management, which is used to manage products and content in the eCommerce website. eCommerce is a platform where we can buy or sell any products or services to the customers through internet. SAP Hybris was originally introduced in 1997 by German based company named Hybris and In 2013, SAP acquired Hybris. Other than SAP Hybris, there are multiple other competitors in the market including: Sales Force Commerce Cloud [Formerly known as Demandware] Adobe Commerce [Formerly known as Magento] HCL Commerce Cloud [Formerly IBM WebSphere Commerce] Oracle CX Commerce BigCommerce Enterprise and etc. Advantages of SAP Hybris over other eCommerce solutions: Advance Search Engine. Seamless Integration with other 3rd party systems. B2B & B2C ...

Groovy Script to fetch available Gift Cards in SAP Hybris:

  In this article, we are going to see how to fetch available Gift Cards in Hybris. Groovy script to fetch available Gift Cards in Hybris: import de.hybris.platform.servicelayer.search.SearchResult; import com.core.model.GiftCardModel; import org.apache.commons.collections4.CollectionUtils; import java.lang.*; import java.util.Collections; // Flexible Search Query fQuery = "Select {PK} from {GiftCard as g JOIN GiftCardType as type on {g.type}={type.pk}} where {type.code} = 'CSR'"; // we can mention any type of the Gift card in where clause. // Initiate necessary services  flexibleSearchService = spring.getBean("flexibleSearchService"); final SearchResult<GiftCardModel> searchResult = flexibleSearchService.search(fQuery); List<GiftCardModel> giftCards = CollectionUtils.isNotEmpty(searchResult.getResult()) ? searchResult.getResult() : Collections.emptyList(); println 'No. of Gift Cards found: ' + giftCards.size(); for (GiftCardModel giftCar...

Creating Gift Cards with INR value using Groovy script in SAP Hybris

In this article, we are going to explore how to create a number of Gift Cards with INR [₹] value using Groovy script in Hybris. Groovy script to create a Gift Cards with INR [ ₹ ] value: import com.core.model.GiftCardModel; import com.core.service.giftcard.GiftCardService; import com.core.enums.GiftCardType; import com.core.enums.GiftCardSourceSystem; // Initiate necessary services  gittCardService = spring.getBean("giftCardService"); userService = spring.getBean("userService"); modelService = spring.getBean("modelService"); int gift_card_count = 10; // Here, pass any number to generate 'n' number of gift cards double gift_card_amount = 100.0; // INR value of the gift card var customer_email = 'dummy@gmail.com'; // provided dummy email id and later on we can share this generated gift card with original customer for (int i = 1; i <= gift_card_count; i++) {           GiftCardModel giftCardModel = giftCardService.giftCardGenerator( gift_car...