Groovy script example
xxxxxxxxxx
import de.hybris.platform.core.Registry
import de.hybris.platform.core.model.user.CustomerModel
import de.hybris.platform.servicelayer.model.ModelService
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery
import de.hybris.platform.servicelayer.search.FlexibleSearchService
import de.hybris.platform.servicelayer.search.SearchResult
final Map<String, Object> params = new HashMap<String, Object>();
String query = "SELECT {c:pk} FROM {customer AS c} where {c:loginDisabled} = '1'" ;
final FlexibleSearchQuery fsquery = new FlexibleSearchQuery(query.toString());
fsquery.addQueryParameters(params);
fsquery.setNeedTotal(false);
fsquery.setCount(10000);
FlexibleSearchService fss = spring.getBean('flexibleSearchService');
ModelService modelService = (ModelService) Registry.getApplicationContext().getBean('modelService');
final SearchResult<CustomerModel> searchResult = fss.search(fsquery);
for (final CustomerModel customer : searchResult.getResult()) {
customer.setPasswordEncoding("pbkdf2");
customer.setEncodedPassword("pwd_!23");
customer.setLoginDisabled(false);
modelService.save(customer);
}
Enable all disabled customers in sap commerce