Showing posts with the label SQL query

Delete Hybris Products having duplicate name from HAC

How to delete duplicate product using the flexible search in Hybris?
Open HAC > console > scripting languages Now you can run the below groovy script 1. Groovy script to get the list of pks to be removed import; flexibleSearchService = spring.getBean("flexibleSearchService") modelService = spring.getBean("modelService") def findProductWithSameName() { query = """ select MIN({}) as pks from {Product! as p JOIN CatalogVersion as CV on {p.catalogversion}={CV:PK} and {CV:version} = 'Online' JOIN Catalog as C on {CV:catalog}={C:PK} and {C:id}='myProductCatalog' } group by {p:name} having count(*) > 1""";; } findProductWithSameName().each { println it.code; //modelService.remove(it); }
2. Test Remove scriptimport; flexibleSe…