sap commerce
Browser-based tools for SAP Commerce Cloud (Hybris) developers. No install, no login, runs entirely client-side.
# tools
// sap-commerce →
ImpEx Generator
Pick a type, fill in your catalog ID — get paste-ready ImpEx with the macros already done.
// sap-commerce →
ImpEx Validator
Paste ImpEx and get a list of issues before running it in HAC. Checks macro definitions, column counts, and missing directives.
// sap-commerce →
FlexibleSearch Builder
Fill in the fields, get a FlexibleSearch query with {pk} and catalog version handled.
// sap-commerce · hac →
Groovy Snippets
Common HAC scripts for Solr, cache, catalog, bulk ops. Searchable, copy-paste ready.
// sap-commerce · rest →
OCC API Snippets
Curl examples for SAP Commerce REST API. Auth, products, carts, orders — headers pre-filled.
// sap-commerce · type-system →
Type System Explorer
Browse common SAP Commerce item types, their attributes, Java types, and localization flags.
# developer notes
impex tips
- Always define
$catalogVersionand$catalogmacros at the top of the file — referencing undefined macros silently inserts blank strings. - Use
INSERT_UPDATEfor most data loads — it upserts without failing on duplicates. UseINSERTonly when you need strict creation semantics. - Test imports on Staged catalog version first, sync to Online only after verification in HAC.
$contentCatalog:catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalogName]),CatalogVersion.version[default=Staged])— the full path for CMS content catalog reference.- Batch size matters: large ImpEx files run faster with
batchSizeheader (default 1, set to 20–100 for bulk inserts).
flexiblesearch gotchas
- Always specify
{catalogVersion}in the WHERE clause when querying product-catalog-aware types — without it you get all versions merged. - Use
{item:pk}not{item.pk}— SAP FlexibleSearch uses curly-brace attribute access, not dot notation. ?startand?countparameters are positional — always add them last, in that order.- Joins across catalog versions are expensive — prefer subqueries or pre-filtered joins in the FROM clause.
- Test in HAC → FlexibleSearch tab before putting into code — the HAC tool shows row count and execution time.
groovy hac patterns
- Always wrap bulk operations in a transaction:
Transaction.current().begin()/commit()/rollback()on catch. - Use
Registry.getApplicationContext().getBean('serviceName')to get Spring beans — don't instantiate services directly. - Script output goes to the return value —
return "done: ${count} items"shows in the HAC result pane. - For large datasets, use
FlexibleSearchServicewith pagination (SearchResult.getResult()) — loading everything into memory causes OOM on large catalogs. - Import statements work:
import de.hybris.platform.core.model.product.ProductModelat the top of the script.
occ api patterns
- The client credentials token endpoint:
POST /authorizationserver/oauth/tokenwithgrant_type=client_credentials— use this for server-to-server calls. - Customer token:
grant_type=password+username+password— needed for customer-specific cart and order operations. - All OCC endpoints use
/rest/v2/{baseSiteId}/prefix by default — check your site'swsCommerceWebServicesContextPathif customised. - Fields projection parameter (
?fields=BASIC|DEFAULT|FULL) controls response verbosity — always request only the fields you need in production. - OAuth2 tokens expire — implement token refresh logic or catch 401s and re-authenticate automatically.