Three Useful GitHub Repos That Every SAP Commerce Developer Should Consider


Flexible Search Builder

Repo: https://github.com/avrilfanomar/flexiblesearchbuilder
License: MIT
Key contributor: Andrii Andriichuk

Flexible Search Builder is a library to take the pain out of generating Flexiblesearch queries in the SAP Commerce code. You can wrap the queries within very lightweight and easy to use Java objects which follow the “builder” paradigm. It helps you to keep you from making foolish errors and make the code nicer and easier to read.

The elements of the builder chain are immutable (unless you pass a mutable parameter and then modify it), thus they can be safely reused among different queries.

Below are some examples of how it works:

final FlexibleSearchQuery query4 =
select(
    FieldWithType.of(ProductModel.NAME, String.class),
    FieldWithType.of(ProductModel.DESCRIPTION, String.class),
    FieldWithType.of(ProductModel.PK, Long.class)
)
.from(
    table(ProductModel.class)
)
.where(
braces(
  condition(ProductModel.SUMMARY, IS_NULL)
  .or()
  .condition(ProductModel.NAME, IS_NOT_NULL)
)
.and()
.condition(ProductModel.PK, BETWEEN, 8796093054977L, 8796193054977L)
)
.build();

The code is basically self-explaining. The library supports grouping, joins, aliases.

final JoinOnElement joinTables =
  table(ProductModel.class).as(p)
   .leftJoin(ProductReferenceModel.class).as(r)
     .on(p.pk(), r.target())
   .leftJoin(OrderEntryModel.class).as(e)
     .on(r.source(), e.field(PRODUCT))
   .leftJoin(OrderModel.class).as(o)
     .on(o.pk(), e.field(ORDER))
   .leftJoin(CategoryConstants.Relations.CATEGORYPRODUCTRELATION).as(c2p)
     .on(r.source(), c2p.target())
   .leftJoin(CategoryModel.class).as(c)
     .on(c.pk(), c2p.source());

See more examples in the README in the root folder.

Video: https://www.youtube.com/watch?v=m25hsW3nqFM 

Repo: https://github.com/avrilfanomar/flexiblesearchbuilder

 

HAC VCS Info

Repo: https://github.com/sap-commerce-tools/hacvcsinfo 
License: Apache License 2.0
Key contributor: Markus Perndorfer

How to figure out what branch was deployed to the environment if all you have is web access to the storefront and backoffice?

This small extension helps to see what version is deployed to a given environment. During the build process, the version metadata from GIT, such as branch id, commit id, and tag, are saved and accessible from HAC.

JHac

Repo: https://github.com/klaushauschild1984/jhac
License: Apache License 2.0
Key contributor: Klaus Hauschild

JHac is a console tool and API for HAC. You can execute code, query, and import data using the API and via an app which you can put inside your automation or integration scripts.

For example, using the following script you can execute a custom code via Groovy Scripting Console available in HAC.

hac()
  .scripting()
  .execute(
    Script.builder()
  .script(
    "spring.beanDefinitionNames.each {\n"
    + " println it\n"
    + "}\n"
    + "return \"Groovy Rocks!\"")
.build());

The following script shows how to fetch data via API:

hac()
  .flexibleSearch()
  .query(
    FlexibleSearchQuery.builder()
   .flexibleSearchQuery("SELECT * FROM { Product }")
  .build());

You can also run the impex script:

hac()
  .impex()
  .importData(
    Impex.builder()
  .scriptContent(
    "INSERT_UPDATE user; uid[unique = true]\n"
    + "; admin")
  .buildImport());
Or export data:

hac()
  .impex()
  .exportData(
    Impex.builder()
  .scriptContent("INSERT_UPDATE user; uid[unique = true]")
  .buildExport());

There is a CLI app built on top of the API which is ready out-of-the-box for some of the operations listed above.

Right now the client app doesn’t support FlexibleSearch yet, but I see from the code that it is trivial to add — contribute! Currently, it supports Groovy, which is basically enough to simulate Flexible Search, Impex Import, and Impex Export.

Other useful repos

CCV2CTL

Repo: https://github.com/sap-commerce-tools/ccv2ctl 

The automation tool from SAP for automating SAP Commerce Cloud build and deployment mechanisms. SAP recently announced the API for the purpose, so it seems that this tool is no longer relevant (?).

SAP Commerce IntelliJ Idea Plugin

Repo: https://github.com/Janhouse/sap-commerce-integration-intellij-idea-plugin 

SAP Commerce/Hybris Integration Intellij IDEA Plugin from Alexander Bartash. This plugin was originally released under GPL 3.0, so this repository contains an open-source fork. The commercial version is available here: https://plugins.jetbrains.com/plugin/7525-hybris-integration 

The open-source version is also available in the jetbrains marketplace (free): https://plugins.jetbrains.com/plugin/12867-sap-commerce-developers-toolset 

Hybris Commerce Eclipse Plugin

Repo: https://github.com/SAP/hybris-commerce-eclipse-plugin 

This plugin takes care of some of the common issues of developing with the SAP Commerce Suite, such as automating importing source code, synchronizing working sets with localextensions, providing an Impex editor, etc. 

Leave a Reply