During our recent migration from hybris 5.7 to 1808 version, I have found that there are few quotes that were migrated but not quote entries under them.
I have decided to remove those quotes from the hybris system. Here is the process I have followed:
- Write a flexible query to find the number of quotes:
SELECT {p:PK} FROM {Quote AS p} WHERE {p:pk} NOT IN ( {{ SELECT {pr:order} FROM {QuoteEntry AS pr} }} ) ORDER BY {p:name} ASC, {p:code} ASC
2. Write a Groovy script to execute this query from hac.
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery; flexibleSearchService = spring.getBean("flexibleSearchService") modelService = spring.getBean("modelService") query = "SELECT {p:pk} FROM {Quote AS p} WHERE {p:pk} NOT IN ({{SELECT {pr:order} FROM {QuoteEntry AS pr}}})"; flexibleSearchService.search(query).result.each { modelService.remove(it) }
3. Login to hac -> console -> scripting languages and use the above script.
4. Make sure to enable “Commit” and hit “Execute”
5. Check the results tab to find out the PKs that got removed from system.