cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Beanshell to remove old carts

Former Member
0 Likes
345

Hi,

I want to write a beanshell to remove all baskets in year 2016. Any help?

Thanks a lot

yamen

Accepted Solutions (0)

Answers (2)

Answers (2)

andyfletcher
Active Contributor
0 Likes

Something like this?

 for (o : spring.getBean("flexibleSearchService").search("select {pk} from {order} where {date} between '2016-01-01' and '2017-01-01'").getResult()) {
   spring.getBean("modelService").remove(o);
 }

or in Groovy

 flexibleSearchService.search(/select {pk} from {order} where {date} between '2016-01-01' and '2017-01-01''/).result.each {
   modelService.remove it
 }
crescenzorega
Active Participant
0 Likes

hi, try to see if it helps

Removing Old Carts with Cronjob https://help.hybris.com/6.7.0/hcd/8c3a6caf866910148cd58d649958d7e2.html