Standard service - a fixed amount of work that is performed at a fixed price.  Post Service


Saturday, 17 November 2018 21:33

Useful Groovy Scripts. Part 7.

Written by
Rate this item
(0 votes)

Previous parts:

    data by e-mail
  • Importing IMPEX
  • Print all properties of an object
  • Print all methods of an object
  • Show the hybris type tree
  • Print hybris type stats
  • PART 2
    • Turn on/off logging for any class
    • Print a bean list from the particular context
    • Executing the method from the page controller bean
    • Print all URLs from all controllers (RequestMappings)
    • Print all web contexts
  • PART 3
    • Flexible Search Generator
  • PART 4
    • Finding all external references to an object (EARLY BETA)
  • PART 5.
    • Restart hybris server
    • Converting FlexibleQuery to SQL
    • All hybris types that use the particular type
    • Executing SQL (DDL)
    • Print mysql table structure from hybris HAC
    • Print all indexes
  • PART 6.
    • Executing an SQL Query. For hybris 6.0+
    • Accessing the file system and fetching a text file via HAC
    • Invalidating a cache for a particular item
    • Executing the multi-column flexibleSearch
    • Executing a long/resource-intensive groovy script
  • PART 7 (this one)
    • Clear Specific Cache Region
  • Clear Specific Cache Region

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


    Turn Off Caching Subsystem

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


    In order to turn it on, change false to true.

    Turn Off the Cronjobs

    It is convinient for debugging the components called from not only the code you troubleshoot, 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";{

    Type system: Get information about a type

    Just change Product with your type in the code below and you will see all attributes, their types, and type classes.


    Create a groovy-powered REST API Server

    Thanks for a great article about the REST API server powered by Groovy in hybris. This approach is great for adding temporary functionality accessible via http protocol.

    CMS: Print all page/slot/component structure


    void showComponentDetails(component){
    println" \\-- "+component.getUid();
    void showSlotDetails(slot){
    println"* "+slot.getUid();
    void showPageDetails(page){

    void showComponents(slot){
    components = slot.getCMSComponents();
    component -> showComponentDetails(component);
    void showSlotsAndComponents(page){

    slots = defaultCMSAdminContentSlotService.getContentSlotsForPage(page);
    slot -> showComponents(slot);
    void showPageConfiguration(AbstractPageModel page){
    template = page.getMasterTemplate();
    println template;


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

    Read 137 times

    Leave a comment

    Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.