@Test public void testProductSkuAttributesView() { final ProductAttributesModel model = productService.getProductAttributes(0L, 9998L, 1L); assertNotNull(model); assertFalse(model.getGroups().isEmpty()); final ProductAttributesModelGroup grp = model.getGroup("3"); assertNotNull(grp); assertEquals("DVD Players view group", grp.getDisplayName("en")); final List<ProductAttributesModelAttribute> attrs = model.getAttributes("WEIGHT"); assertEquals(1, attrs.size()); assertEquals("Weight", attrs.get(0).getDisplayName("en")); final ProductAttributesModelAttribute attr = grp.getAttribute("WEIGHT"); assertNotNull(attr); assertEquals("Weight", attr.getDisplayName("en")); final List<ProductAttributesModelValue> values = attr.getValues(); assertEquals(1, values.size()); assertEquals("1.16", values.get(0).getVal()); }
@Override public ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId) { final ProductSku sku = skuId != 0L ? proxy().getSkuById(skuId, true) : null; final Product product = productId != 0L ? proxy().getProductById(productId, true) : (sku != null ? proxy().getProductById(sku.getProduct().getProductId(), true) : null); Collection<AttrValue> productAttrValues; Collection<AttrValue> skuAttrValues; if (sku != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = sku.getAllAttributes(); } else if (product != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = Collections.emptyList(); } else { return new ProductAttributesModelImpl(productId, null, skuId, null, productTypeId); } final List<ProductAttributesModelGroupImpl> attributeViewGroups = mapAttributeGroupsByAttributeCode(productTypeId); final ProductAttributesModelImpl attributesToShow; if (sku != null) { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), sku.getSkuId(), sku.getCode(), productTypeId, (List) attributeViewGroups); } else { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), 0L, null, productTypeId, (List) attributeViewGroups); } for (final AttrValue attrValue : productAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } for (final AttrValue attrValue : skuAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } return attributesToShow; }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId) { final ProductSku sku = skuId != 0L ? proxy().getSkuById(skuId, true) : null; final Product product = productId != 0L ? proxy().getProductById(productId, true) : (sku != null ? proxy().getProductById(sku.getProduct().getProductId(), true) : null); Collection<AttrValue> productAttrValues; Collection<AttrValue> skuAttrValues; if (sku != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = sku.getAllAttributes(); } else if (product != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = Collections.emptyList(); } else { return new ProductAttributesModelImpl(productId, null, skuId, null, productTypeId); } final List<ProductAttributesModelGroupImpl> attributeViewGroups = mapAttributeGroupsByAttributeCode(productTypeId); final ProductAttributesModelImpl attributesToShow; if (sku != null) { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), sku.getSkuId(), sku.getCode(), productTypeId, (List) attributeViewGroups); } else { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), 0L, null, productTypeId, (List) attributeViewGroups); } for (final AttrValue attrValue : productAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } for (final AttrValue attrValue : skuAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } return attributesToShow; } }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId) { final ProductSku sku = skuId != 0L ? proxy().getSkuById(skuId, true) : null; final Product product = productId != 0L ? proxy().getProductById(productId, true) : (sku != null ? proxy().getProductById(sku.getProduct().getProductId(), true) : null); Collection<AttrValue> productAttrValues; Collection<AttrValue> skuAttrValues; if (sku != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = sku.getAllAttributes(); } else if (product != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = Collections.emptyList(); } else { return new ProductAttributesModelImpl(productId, null, skuId, null, productTypeId); } final List<ProductAttributesModelGroupImpl> attributeViewGroups = mapAttributeGroupsByAttributeCode(productTypeId); final ProductAttributesModelImpl attributesToShow; if (sku != null) { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), sku.getSkuId(), sku.getCode(), productTypeId, (List) attributeViewGroups); } else { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), 0L, null, productTypeId, (List) attributeViewGroups); } for (final AttrValue attrValue : productAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } for (final AttrValue attrValue : skuAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } return attributesToShow; } ProductServiceImpl(final GenericFTSCapableDAO<Product, Long, Object> productDao,
                              final GenericFTSCapableDAO<ProductSku, Long, Object> productSkuDao,
                              final ProductSkuService productSkuService,
                              final ProductTypeAttrService productTypeAttrService,
                              final AttributeService attributeService,
                              final GenericDAO<ProductCategory, Long> productCategoryDao,
                              final GenericDAO<ProductTypeAttr, Long> productTypeAttrDao,
                              final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId) { final ProductSku sku = skuId != 0L ? proxy().getSkuById(skuId, true) : null; final Product product = productId != 0L ? proxy().getProductById(productId, true) : (sku != null ? proxy().getProductById(sku.getProduct().getProductId(), true) : null); Collection<AttrValue> productAttrValues; Collection<AttrValue> skuAttrValues; if (sku != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = sku.getAllAttributes(); } else if (product != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = Collections.emptyList(); } else { return new ProductAttributesModelImpl(productId, null, skuId, null, productTypeId); } final List<ProductAttributesModelGroupImpl> attributeViewGroups = mapAttributeGroupsByAttributeCode(productTypeId); final ProductAttributesModelImpl attributesToShow; if (sku != null) { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), sku.getSkuId(), sku.getCode(), productTypeId, (List) attributeViewGroups); } else { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), 0L, null, productTypeId, (List) attributeViewGroups); } for (final AttrValue attrValue : productAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } for (final AttrValue attrValue : skuAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } return attributesToShow; } ProductServiceImpl(final GenericFTSCapableDAO<Product, Long, Object> productDao,
                              final GenericFTSCapableDAO<ProductSku, Long, Object> productSkuDao,
                              final ProductSkuService productSkuService,
                              final ProductTypeAttrService productTypeAttrService,
                              final AttributeService attributeService,
                              final GenericDAO<ProductCategory, Long> productCategoryDao,
                              final GenericDAO<ProductTypeAttr, Long> productTypeAttrDao,
                              final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); @Override ProductSku getSkuById(final Long skuId); @Override ProductSku getSkuById(final Long skuId, final boolean withAttributes); @Override String getDefaultImage(final Long productId); @Override ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId); @Override ProductCompareModel getCompareAttributes(final List<Long> productId,
                                                    final List<Long> skuId); @Override Map<Long, String> getAllProductsAttributeValues(final String attributeCode); @Override ProductSku getProductSkuByCode(final String skuCode); @Override Product getProductBySkuCode(final String skuCode); @Override Product getProductById(final Long productId); @Override Product getProductById(final Long productId, final boolean withAttribute); @Override ProductSearchResultPageDTO getProductSearchResultDTOByQuery(final NavigationContext navigationContext,
                                                                       final int firstResult,
                                                                       final int maxResults,
                                                                       final String sortFieldName,
                                                                       final boolean reverse); @Override ProductSearchResultNavDTO findFilteredNavigationRecords(final NavigationContext baseNavigationContext, final List<FilteredNavigationRecordRequest> request); @Override int getProductQty(final NavigationContext navigationContext); @Override Pair<Integer, Integer> findProductQtyAll(); @Override List<Product> getProductByIdList(final List idList); @Override Long findProductIdBySeoUri(final String seoUri); @Override Long findProductIdByGUID(final String guid); @Override Long findProductIdByCode(final String code); @Override List<Long> findProductIdsByManufacturerCode(final String code); @Override List<Long> findProductIdsByBarCode(final String code); @Override List<Long> findProductIdsByBarCodes(final Collection<String> codes); @Override List<Long> findProductIdsByPimCode(final String code); @Override List<Long> findProductIdsByAttributeValue(final String attrCode, final String attrValue); @Override String findSeoUriByProductId(final Long productId); @Override Long findProductSkuIdBySeoUri(final String seoUri); @Override Long findProductSkuIdByGUID(final String guid); @Override Long findProductSkuIdByCode(final String code); @Override String findSeoUriByProductSkuId(final Long skuId); @Override IndexBuilder.FTIndexState getProductsFullTextIndexState(); @Override IndexBuilder.FTIndexState getProductsSkuFullTextIndexState(); @Override void reindexProducts(final int batchSize); @Override void reindexProducts(final int batchSize, final boolean async); @Override void reindexProductsSku(final int batchSize); @Override void reindexProductsSku(final int batchSize, final boolean async); @Override void reindexProducts(final Long shopId, final int batchSize); @Override void reindexProductsSku(final Long shopId, final int batchSize); @Override void reindexProduct(final Long pk); @Override void reindexProductSku(final Long pk); @Override void reindexProductSku(final String code); @Override List<Product> findProducts(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findProductCount(final Map<String, List> filter); @Override List<Product> findProductByCodeNameBrandType(final String code,
                                                        final String name,
                                                        final Long brandId,
                                                        final Long productTypeId); @Override List<String> findProductSupplierCatalogCodes(); @Override Product create(final Product instance); ProductService getSelf(); }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId) { final ProductSku sku = skuId != 0L ? proxy().getSkuById(skuId, true) : null; final Product product = productId != 0L ? proxy().getProductById(productId, true) : (sku != null ? proxy().getProductById(sku.getProduct().getProductId(), true) : null); Collection<AttrValue> productAttrValues; Collection<AttrValue> skuAttrValues; if (sku != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = sku.getAllAttributes(); } else if (product != null) { productAttrValues = product.getAllAttributes(); skuAttrValues = Collections.emptyList(); } else { return new ProductAttributesModelImpl(productId, null, skuId, null, productTypeId); } final List<ProductAttributesModelGroupImpl> attributeViewGroups = mapAttributeGroupsByAttributeCode(productTypeId); final ProductAttributesModelImpl attributesToShow; if (sku != null) { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), sku.getSkuId(), sku.getCode(), productTypeId, (List) attributeViewGroups); } else { attributesToShow = new ProductAttributesModelImpl(product.getProductId(), product.getCode(), 0L, null, productTypeId, (List) attributeViewGroups); } for (final AttrValue attrValue : productAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } for (final AttrValue attrValue : skuAttrValues) { loadAttributeValueToAttributesToShowMap(attributesToShow, attrValue); } return attributesToShow; } ProductServiceImpl(final GenericFTSCapableDAO<Product, Long, Object> productDao,
                              final GenericFTSCapableDAO<ProductSku, Long, Object> productSkuDao,
                              final ProductSkuService productSkuService,
                              final ProductTypeAttrService productTypeAttrService,
                              final AttributeService attributeService,
                              final GenericDAO<ProductCategory, Long> productCategoryDao,
                              final GenericDAO<ProductTypeAttr, Long> productTypeAttrDao,
                              final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); @Override ProductSku getSkuById(final Long skuId); @Override ProductSku getSkuById(final Long skuId, final boolean withAttributes); @Override String getDefaultImage(final Long productId); @Override ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId); @Override ProductCompareModel getCompareAttributes(final List<Long> productId,
                                                    final List<Long> skuId); @Override Map<Long, String> getAllProductsAttributeValues(final String attributeCode); @Override ProductSku getProductSkuByCode(final String skuCode); @Override Product getProductBySkuCode(final String skuCode); @Override Product getProductById(final Long productId); @Override Product getProductById(final Long productId, final boolean withAttribute); @Override ProductSearchResultPageDTO getProductSearchResultDTOByQuery(final NavigationContext navigationContext,
                                                                       final int firstResult,
                                                                       final int maxResults,
                                                                       final String sortFieldName,
                                                                       final boolean reverse); @Override ProductSearchResultNavDTO findFilteredNavigationRecords(final NavigationContext baseNavigationContext, final List<FilteredNavigationRecordRequest> request); @Override int getProductQty(final NavigationContext navigationContext); @Override Pair<Integer, Integer> findProductQtyAll(); @Override List<Product> getProductByIdList(final List idList); @Override Long findProductIdBySeoUri(final String seoUri); @Override Long findProductIdByGUID(final String guid); @Override Long findProductIdByCode(final String code); @Override List<Long> findProductIdsByManufacturerCode(final String code); @Override List<Long> findProductIdsByBarCode(final String code); @Override List<Long> findProductIdsByBarCodes(final Collection<String> codes); @Override List<Long> findProductIdsByPimCode(final String code); @Override List<Long> findProductIdsByAttributeValue(final String attrCode, final String attrValue); @Override String findSeoUriByProductId(final Long productId); @Override Long findProductSkuIdBySeoUri(final String seoUri); @Override Long findProductSkuIdByGUID(final String guid); @Override Long findProductSkuIdByCode(final String code); @Override String findSeoUriByProductSkuId(final Long skuId); @Override IndexBuilder.FTIndexState getProductsFullTextIndexState(); @Override IndexBuilder.FTIndexState getProductsSkuFullTextIndexState(); @Override void reindexProducts(final int batchSize); @Override void reindexProducts(final int batchSize, final boolean async); @Override void reindexProductsSku(final int batchSize); @Override void reindexProductsSku(final int batchSize, final boolean async); @Override void reindexProducts(final Long shopId, final int batchSize); @Override void reindexProductsSku(final Long shopId, final int batchSize); @Override void reindexProduct(final Long pk); @Override void reindexProductSku(final Long pk); @Override void reindexProductSku(final String code); @Override List<Product> findProducts(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findProductCount(final Map<String, List> filter); @Override List<Product> findProductByCodeNameBrandType(final String code,
                                                        final String name,
                                                        final Long brandId,
                                                        final Long productTypeId); @Override List<String> findProductSupplierCatalogCodes(); @Override Product create(final Product instance); ProductService getSelf();  }