/** * Populates the elements in tree with the information retrieved from the variant.. * * @param productModel the product to take the data from. * @param productData the data to put the data in. * @throws de.hybris.platform.servicelayer.dto.converter.ConversionException */ @Override public void populate(final ProductModel productModel, final ProductData productData) throws ConversionException { final Collection<VariantProductModel> variants = getVariants(productModel); for (final VariantProductModel variant : variants) { populateNodes(productData.getVariantMatrix(), variant, productModel); } }
/** * JSP EL Function to get an image for a Product in a specific format based on the product code. * * @param product The product. * @param productCode The desired product code. * @param format The desired format. * @return The image. */ public static ImageData getImageForProductCode( final ProductData product, final String productCode, final String format) { if (product != null && productCode != null && format != null) { int selectedIndex = 0; for (int i = 1; i <= product.getCategories().size(); i++) { int j = 0; final List<VariantMatrixElementData> theMatrix; if (i == 1) { theMatrix = product.getVariantMatrix(); } else { theMatrix = product.getVariantMatrix().get(selectedIndex).getElements(); selectedIndex = 0; } if (theMatrix.get(selectedIndex).getParentVariantCategory().getHasImage()) { for (final VariantMatrixElementData matrixElementData : theMatrix) { if (matrixElementData.getVariantOption().getVariantOptionQualifiers() != null && productCode.equals(matrixElementData.getVariantOption().getCode())) { for (final VariantOptionQualifierData variantOption : matrixElementData.getVariantOption().getVariantOptionQualifiers()) { if (format.equals(variantOption.getImage().getFormat())) { return variantOption.getImage(); } } selectedIndex = j; } j++; } } } } return null; }