diff --git a/sm-shop/src/main/java/com/salesmanager/shop/mapper/inventory/PersistableInventoryMapper.java b/sm-shop/src/main/java/com/salesmanager/shop/mapper/inventory/PersistableInventoryMapper.java index 087b101a18..b4212ebe84 100644 --- a/sm-shop/src/main/java/com/salesmanager/shop/mapper/inventory/PersistableInventoryMapper.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/mapper/inventory/PersistableInventoryMapper.java @@ -41,10 +41,10 @@ public class PersistableInventoryMapper implements Mapper 0) { - Product product = productService.findOne(source.getId(), store); + Product product = productService.findOne(source.getProductId().longValue(), store); if(product == null) { throw new ResourceNotFoundException("Product with id [" + source.getId() + "] not found for store [" + store.getCode() + "]"); } diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductApi.java b/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductApi.java index c1bddd1962..7770a25c75 100755 --- a/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductApi.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductApi.java @@ -83,7 +83,7 @@ public class ProductApi { @Autowired private ProductFacade productFacade; - + @Inject private ProductCommonFacade productCommonFacade; @@ -147,10 +147,10 @@ public class ProductApi { @ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "string", defaultValue = "en") }) public void update( - @PathVariable Long id, - @Valid @RequestBody + @PathVariable Long id, + @Valid @RequestBody LightPersistableProduct product, - @ApiIgnore MerchantStore merchantStore, + @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) { productCommonFacade.update(id, product, merchantStore, language); return; @@ -199,13 +199,15 @@ public ReadableProductList list( // allowing // navigation @RequestParam(value = "count", required = false, defaultValue = "100") Integer count, // count + @RequestParam(value = "slug", required = false) String slug, // category slug + @RequestParam(value = "available", required = false) Boolean available, // per // page @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language, HttpServletRequest request, HttpServletResponse response) throws Exception { ProductCriteria criteria = new ProductCriteria(); - + criteria.setOrigin(origin); // do not use legacy pagination anymore @@ -217,11 +219,24 @@ public ReadableProductList list( if (!StringUtils.isBlank(status)) { criteria.setStatus(status); } + // Start Category handling + List categoryIds = new ArrayList(); + if (slug != null) { + Category categoryBySlug = categoryService.getBySeUrl(merchantStore, slug); + categoryIds.add(categoryBySlug.getId()); + } if (category != null) { - List categoryIds = new ArrayList(); categoryIds.add(category); + } + if (categoryIds.size() > 0) { criteria.setCategoryIds(categoryIds); } + // End Category handling + + if (available != null && available) { + criteria.setAvailable(available); + } + if (manufacturer != null) { criteria.setManufacturerId(manufacturer); } @@ -315,7 +330,7 @@ public ReadableProduct get(@PathVariable final Long id, @RequestParam(value = "l @ResponseBody @ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") }) - public ReadableProductPrice price(@PathVariable final Long id, + public ReadableProductPrice price(@PathVariable final Long id, @RequestBody ProductPriceRequest variants, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) { @@ -461,7 +476,7 @@ public ResponseEntity exists(@RequestParam(value = "code") String /** * Change product sort order - * + * * @param id * @param position * @param merchantStore