Posts

Showing posts with the label Hybris Coding

Groovy Script to fetch available Gift Cards in SAP Hybris:

  In this article, we are going to see how to fetch available Gift Cards in Hybris. Groovy script to fetch available Gift Cards in Hybris: import de.hybris.platform.servicelayer.search.SearchResult; import com.core.model.GiftCardModel; import org.apache.commons.collections4.CollectionUtils; import java.lang.*; import java.util.Collections; // Flexible Search Query fQuery = "Select {PK} from {GiftCard as g JOIN GiftCardType as type on {g.type}={type.pk}} where {type.code} = 'CSR'"; // we can mention any type of the Gift card in where clause. // Initiate necessary services  flexibleSearchService = spring.getBean("flexibleSearchService"); final SearchResult<GiftCardModel> searchResult = flexibleSearchService.search(fQuery); List<GiftCardModel> giftCards = CollectionUtils.isNotEmpty(searchResult.getResult()) ? searchResult.getResult() : Collections.emptyList(); println 'No. of Gift Cards found: ' + giftCards.size(); for (GiftCardModel giftCar...

Creating Gift Cards with INR value using Groovy script in SAP Hybris

In this article, we are going to explore how to create a number of Gift Cards with INR [₹] value using Groovy script in Hybris. Groovy script to create a Gift Cards with INR [ ₹ ] value: import com.core.model.GiftCardModel; import com.core.service.giftcard.GiftCardService; import com.core.enums.GiftCardType; import com.core.enums.GiftCardSourceSystem; // Initiate necessary services  gittCardService = spring.getBean("giftCardService"); userService = spring.getBean("userService"); modelService = spring.getBean("modelService"); int gift_card_count = 10; // Here, pass any number to generate 'n' number of gift cards double gift_card_amount = 100.0; // INR value of the gift card var customer_email = 'dummy@gmail.com'; // provided dummy email id and later on we can share this generated gift card with original customer for (int i = 1; i <= gift_card_count; i++) {           GiftCardModel giftCardModel = giftCardService.giftCardGenerator( gift_car...