Groovy web console

subscribe to the feed Subscribe
to this
site
richemont_product_cache (via #groovywebconsole)
tweet this snippet Tweet
this
script

richemont_product_cache

Published 5 months ago by richemont
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import org.apache.commons.lang.*
import com.richemont.cms.base.commerce.product.api.*
import com.richemont.cms.base.services.configuration.*
import com.richemont.cms.base.commerce.common.*
 
 
//US is an example region code
def priceService = getServices("com.richemont.cms.base.commerce.api.ProductPriceService", "(cached=true)")[0]
 
//key is REFID-REGION_CODE
priceService.addPriceDataToCache(["PNPAM00312-US":(Double)1220.0] as Map)
 
def availService = getServices("com.richemont.cms.base.commerce.api.ProductAvailabilityService", "(cached=true)")[0]
//binary flags: bit0 - stock, bit1 - sellable
//key is web-REFID-REGION_CODE
availService.addAvailabilityDataToCache(["web-PNPAM00312-US":(byte)(1/*stock-isAvailable*/+2/*isSellable*/)])