Groovy Script to print all the products based on some criteria flexible search query

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

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

import de.hybris.platform.core.model.product.ProductModel;

import java.util.ArrayList;

import java.util.List;


import com.elverys.core.model.ApparelStyleVariantProductModel;


FlexibleSearchService flexibleSearchService = spring.getBean("flexibleSearchService");


List<ApparelStyleVariantProductModel> duplicateBrands  = new ArrayList<ApparelStyleVariantProductModel>();


FlexibleSearchQuery flexibleSearchQuery = new FlexibleSearchQuery("select {pk} from {ApparelStyleVariantProduct! as ap JOIN CatalogVersion AS cv ON {ap:catalogVersion} = {cv:PK}} where {cv:active} = 0 AND {cv:version} = 'Staged' AND {ap:giftCardProduct} = '0'");

duplicateBrands.addAll(flexibleSearchService.search(flexibleSearchQuery).getResult());


int count = 0;

for(ApparelStyleVariantProductModel obj:duplicateBrands)

   {

count++;

if(obj.getVariants().isEmpty())

{

System.out.println(obj.getBaseProduct().getCode()+"::"+ obj.getCode());

}

   }

println count;


return "success";

Comments

Popular Posts