A note from 2026: This article was published in 2018, when SAP Commerce was still commonly referred to as hybris. Some internal APIs, CMS services, and HAC/Groovy scripting practices shown here may differ or be restricted in current SAP Commerce Cloud and CCv2 environments.

Previous parts:

Clear Specific Cache Region

This approach is useful for troubleshooting database interaction. After clearing the cache before the operation, subsequent commands or requests will be performed with no data in the caches, and you can be sure that all SQL statements generated after this point will be properly logged in the JDBC log, at least once.

defaultCacheController.clearCache(entityCacheRegion);
defaultCacheController.clearCache(queryCacheRegion);
defaultCacheController.clearCache(mediaCacheRegion);
defaultCacheController.clearCache(cmsCacheRegion);

Turn Off Caching Subsystem

Warning! Your system will work tremendously slowly after applying this setting. You can turn the cache off, perform some operations, and turn it on again for debugging purposes or to collect performance metrics.

tenant.getCurrentTenant().getCache().setEnabled(false);

To turn it on, change false to true.

Turn Off the Cronjobs

It is convenient for debugging components called not only from the code you are troubleshooting, but from cronjobs too. To ease the process, turn all cronjobs off by setting active to false.

q = "select {pk} from {CronJob} where {active} = true";
flexibleSearchService.search(q).getResult().each {
    it.setActive(false); modelService.save(it);
}

Type system: Get information about a type

Change Product to your type in the code below, and you will see all attributes, their types, and type classes.

de.hybris.platform.core.Registry.getPersistenceManager().getPersistenceInfo("Product");

Persistence information for the Product type in SAP Commerce

Create a Groovy-powered REST API Server

Thanks to hybrisarchitect.com for a great article about a REST API server powered by Groovy in hybris. This approach is great for adding temporary functionality accessible via the HTTP protocol. https://hybrisarchitect.com/how-to-build-a-rapid-prototype-rest-api-server-using-sap-hybris-commerce/

CMS: Print all page/slot/component structure

import de.hybris.platform.cms2.enums.CmsPageStatus;
import de.hybris.platform.cms2.model.pages.AbstractPageModel;

void showComponentDetails(component) {
    println " \\-- " + component.getUid();
}

void showSlotDetails(slot) {
    println "* " + slot.getUid();
}

void showPageDetails(page) {
    println "[" + page.getUid() + "]";
}

void showComponents(slot) {
    showSlotDetails(slot);
    components = slot.getCMSComponents();
    components.each {
        component -> showComponentDetails(component);
    }
}

void showSlotsAndComponents(page) {
    slots = defaultCMSAdminContentSlotService.getContentSlotsForPage(page);
    slots.each {
        slot -> showComponents(slot);
    }
}

void showPageConfiguration(AbstractPageModel page) {
    showPageDetails(page);
    template = page.getMasterTemplate();
    println template;
    showSlotsAndComponents(page);
}

SUCCESS_STATUS = Arrays.asList(CmsPageStatus.ACTIVE);
catalogVersionStaged = catalogVersionService.getCatalogVersion("lynxContentCatalog", "Staged");
pages = defaultCMSAdminPageService.getAllPagesForCatalogVersionAndPageStatuses(catalogVersionStaged, SUCCESS_STATUS);
site = defaultCMSAdminSiteService.getSiteForId("lynx");
sessionService.setAttribute("activeCatalogVersion", catalogVersionStaged.getPk());
sessionService.setAttribute("activeSite", site.getPk());
pages.each {
    page ->
    showPageConfiguration(page);
}