Tags

38 pages

SAP Commerce

Improve test run in hybris

OOTB hybris provides ant unittests command to run unit and integration tests, which are pretty low level and requires additional configuration to simplify run and result collection for DevOps. Below you can find configuration for buildcallbacks.xml, which you can just copy-paste into any hybris project (version 6.0+) and significantly simplify DevOps job required for setup of CI/CD pipeline.

Synchronize catalogs from business process

Starting catalog synchronization with CatalogVersionSyncJob in a bussiness process action leads to “Error in worker SyncWorker : Entity not found ( pk = 8794627343487 name = ‘de.hybris.platform.persistence.processing_CronJob’ type code = ‘501’ db table = ‘cronjobs’)”. I didn’t find a way to fix such behaviour of syncing inside business process action, but I resolved this issue by triggering event from process action and running SyncJob in event listener. For me sync performs well only via SetupSyncJobService, performing job via CatalogSynchronizationService causes exception in SyncWorker.

How to sync prices of base product to its variants

Sometimes simple tasks like “On base product price change also change price for all its sub products” can lead to long nights of debugging and seeking of workarounds. Sounds like this task should be easy for implementation. Create PrepareInterceptor, check if price was changed with InterceptorContext.isModified() method, iterate all sub products and put the new price.

Switch solr client on POST requests

From time to time I have been receiving from customer support service messages that filter functionality on PLP returns no results. Finally, after 1 year of such messages our QA team was able to reproduce the issue. The root of the issue is too many filters, which causes creation of very long requests, which can’t be processed by solr server. Solr server is shipped with Jetty, which has 8KB limit to URL length. You can change this limit by adding <Set name="requestHeaderSize"> 200000 </Set> to server/contexts/solr-jetty-context.xml. After discussions with DevOps Lead and Tech Lead we decided that in our case will be better to force hybris solr client to use POST requests instead of GET and don’t change solr server OOTB settings (by default Jetty has limitation to 200KB for POST body). Unfortunately hybris doesn’t provide any configuration for such switching, and it must be done manually by overriding DefaultFacetSearchStrategy.

How to speed up groovy scripts

I had a task to optimize user creation and storing. Before changes on each anonymous checkout a new user was creates with ID in format RANDOM_UID|USER_EMAILand we had a lot of users who used anonymous checkout more than once. After changes only one user with ID in format USER_EMAIL for all anonymous checkouts was used. As a part of the task I need to migrate all old users to new format users. First version of moigration script had an execution time took more than 3 days for processing around 7 millions of people.