After adding 2 products to the cart from AcceleratorStorefront, I have deleted those products via the Backoffice. When I tried quering the CartEntry type via Flexible search query in hac, the product column for those cart entries still referring a PK.
I have tried the following snippet and it returned 0 entries. My expectation is 2 entries as I have deleted 2 products.
return flexibleSearchService.<CartEntryModel>search("select {PK} from {CartEntry} where {product} IS NULL").getResult().size();
But the same query returned expected result, when executed after accessing the cart entries from the backoffice or calling cartEntry.getProduct()
via code. How do I get the expected result wihout doing so?
sai gokul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
You are trying an expected behavior. Normally we never delete products from online catalog. Because we have order history, email messages, etc. We just mark them as not sellable (hidden). We have data retention framework for removing old data after long times (it depends on your company, many 3 year, maybe 6 months). During deleting this kind of data we are checking relations and sometimes we don’t delete them.
Normally hybris has cascade logic to delete related items. We are using partOf modifiers for an attribute. But if you have a lot of data likes order entries it creates performance bottleneck. Also you don’t want to delete related items because of you don’t want to lost the history.
You are getting empty result because hybris has logic to check product still there and has valid data.
2