Created
September 21, 2018 17:30
-
-
Save jparbros/56597eb2f1e18781e8f9bef2329ffa92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
importPackage( dw.util ); | |
importPackage( dw.system ); | |
importPackage( dw.catalog ); | |
var ProductUtils = require('app_storefront_core/cartridge/scripts/product/ProductUtils.js'); | |
function execute(Product, CurrentVariationModel) { | |
var pvm : ProductVariationModel = empty(CurrentVariationModel) ? Product.variationModel : CurrentVariationModel; | |
if (Product.isMaster()) { | |
//get the first selected variant | |
Product = (pvm.getSelectedVariants().length > 0) ? pvm.getSelectedVariants()[0] : pvm.getVariants()[0]; | |
} | |
var variationGroups : Collection = ProductUtils.getSelectedVariationGroups(Product); | |
var VariationGroup = (variationGroups.size() > 0) ? variationGroups[0] : null; | |
return VariationGroup; | |
} | |
module.export = { | |
execute: execute | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment