Skip to content

Commit

Permalink
Merge pull request #771 from jinoteco/master
Browse files Browse the repository at this point in the history
- Fix to find product creating ProductAvailability
  • Loading branch information
shopizer-ecommerce authored Jun 23, 2022
2 parents 46048ee + f656e58 commit 2c6ea83
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class PersistableInventoryMapper implements Mapper<PersistableInventory,

@Autowired
private LanguageService languageService;

@Autowired
private ProductInstanceService productInstanceService;

@Autowired
private ProductService productService;

Expand Down Expand Up @@ -75,9 +75,9 @@ public ProductAvailability merge(PersistableInventory source, ProductAvailabilit
if (StringUtils.isNotBlank(source.getDateAvailable())) {
destination.setProductDateAvailable(DateUtil.getDate(source.getDateAvailable()));
}

if(source.getProductId()!= null && source.getProductId().longValue() > 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() + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class ProductApi {

@Autowired
private ProductFacade productFacade;

@Inject
private ProductCommonFacade productCommonFacade;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -217,11 +219,24 @@ public ReadableProductList list(
if (!StringUtils.isBlank(status)) {
criteria.setStatus(status);
}
// Start Category handling
List<Long> categoryIds = new ArrayList<Long>();
if (slug != null) {
Category categoryBySlug = categoryService.getBySeUrl(merchantStore, slug);
categoryIds.add(categoryBySlug.getId());
}
if (category != null) {
List<Long> categoryIds = new ArrayList<Long>();
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);
}
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -461,7 +476,7 @@ public ResponseEntity<EntityExists> exists(@RequestParam(value = "code") String

/**
* Change product sort order
*
*
* @param id
* @param position
* @param merchantStore
Expand Down

0 comments on commit 2c6ea83

Please sign in to comment.