Groovy script to delete all prodcts from a catalog version

flexibleSearchService.search(/select {PK} from {product} WHERE {catalogversion} =8796355265113/).result.each {

   modelService.remove(it)}


or we can use below


import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;


int count = 1000;

 String query = "select {PK} from {product} WHERE {catalogversion} =8796355265113"

 FlexibleSearchQuery flexiQuery = new FlexibleSearchQuery(query);

 flexiQuery.setCount(count); 

 

flexibleSearchService.search(flexiQuery).result.each {

   modelService.remove(it)}

Comments

Popular Posts