Skip to Content
0
Former Member
Jun 18, 2015 at 09:20 AM

How to get classification attributes specific to a product from classification class

349 Views

I am able to go till classificationData . However the Feature Data is null though there are attributes defined.

final CatalogVersionModel catalogVersionModel = catalogVersionService.getCatalogVersion(catalogId, catalogVersionId);

final ProductGroupDTO productGroupDTO = productGroupDataFacade.retrieveProductGroup(catalogVersionModel, productGroupCode);

     model.addAttribute("productGroupData", productGroupDTO);
     final QIAProductGroupModel qiaproduct = (QIAProductGroupModel) productService.getProductForCode(catalogVersionModel,
             productGroupDTO.getCode());
     final ProductModel pmodel = productService.getProductForCode(catalogVersionModel, productGroupDTO.getCode());
     
     
     final ProductModel product = qiaproduct;
     

     
     final ClassificationSystemVersionModel versions = classificationService.getSystemVersion(myclassificationsystem, version);

 
     final List<SpecificationData> specificationdata = new ArrayList<SpecificationData>(); 


     final List<ProductOption> options = new ArrayList<>(Arrays.asList(ProductOption.BASIC, ProductOption.PRICE,
             ProductOption.SUMMARY, ProductOption.DESCRIPTION, ProductOption.GALLERY, ProductOption.CATEGORIES,
             ProductOption.REVIEW, ProductOption.PROMOTIONS, ProductOption.CLASSIFICATION, ProductOption.VARIANT_FULL,
             ProductOption.STOCK, ProductOption.VOLUME_PRICES, ProductOption.PRICE_RANGE));
     final ProductModel productModel = productService.getProductForCode(productGroupDTO.getCode());
     final ProductData productData = productFacade.getProductForOptions(productModel, options);
     for (final ClassificationData classificationData : productData.getClassifications())
     {
         if (classificationData != null)
         {
             for (final FeatureData featureData : classificationData.getFeatures())
             {

                 if (featureData != null)
                 {
                     LOG.info("featureData" + classificationData.getFeatures().size() + featureData.getName());
                     final int i = 0;
                     specificationdata.get(i).setSpecname(featureData.getName());
                     for (final FeatureValueData featureValueData : featureData.getFeatureValues())
                     {
                         if (featureValueData != null)
                         {
                             LOG.info("featureData" + featureData.getFeatureValues());
                             final List<String> specvalue = new ArrayList<String>();
                             specvalue.add(featureValueData.getValue());
                             specificationdata.get(i).setSpecvalue(specvalue);

                         }
                     }
                 }
             }
         }
     }