public interface ProductVariantAvailabilitySortSearchModel<T>
Modifier and Type | Method and Description |
---|---|
MultiValueSortSearchModel<T> |
availableQuantity()
Model to formulate search requests with by availableQuantity.
|
ChannelsProductVariantAvailabilitySortSearchModel<T> |
channels() |
MultiValueSortSearchModel<T> |
restockableInDays()
Model to formulate search requests with sorting by restockable in days.
|
MultiValueSortSearchModel<T> restockableInDays()
Example without channels:
withProductOfRestockableInDaysAndChannel(client(), 4, null, product4 -> { withProductOfRestockableInDaysAndChannel(client(), 9, null, product9 -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .plusQueryFilters(m -> m.id().isIn(asList(product4.getId(), product9.getId()))) .plusSort(m -> m.allVariants().availability().restockableInDays().asc()); assertEventually(() -> { final PagedSearchResult<ProductProjection> res = client().executeBlocking(request); assertThat(res.getResults()).hasSize(2); assertThat(res.getResults().get(0).getId()) .isEqualTo(product4.getId()); }); }); });
See the test code.
Example with a channel:
withChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY, channel -> { withProductOfRestockableInDaysAndChannel(client(), 4, channel, product4 -> { withProductOfRestockableInDaysAndChannel(client(), 9, channel, product9 -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .plusQueryFilters(m -> m.id().isIn(asList(product4.getId(), product9.getId()))) .plusSort(m -> m.allVariants().availability().channels().channelId(channel.getId()).restockableInDays().asc()); assertEventually(() -> { final PagedSearchResult<ProductProjection> res = client().executeBlocking(request); assertThat(res.getResults()).hasSize(2); assertThat(res.getResults().get(0).getId()) .isEqualTo(product4.getId()); }); }); }); });
See the test code.
MultiValueSortSearchModel<T> availableQuantity()
Example without channels:
withProductOfStock(client(), 10, productWith10Items -> { withProductOfStock(client(), 5, productWith5Items -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .plusQueryFilters(m -> m.id().isIn(asList(productWith5Items.getId(), productWith10Items.getId()))) .plusSort(m -> m.allVariants().availability().availableQuantity().asc()); assertEventually(() -> { final PagedSearchResult<ProductProjection> res = client().executeBlocking(request); assertThat(res.getResults()).hasSize(2); assertThat(res.getResults().get(0).getId()) .isEqualTo(productWith5Items.getId()); }); }); });
See the test code.
Example with a channel:
withChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY, channel -> { withProductOfStockAndChannel(client(), 10, channel, productWith10Items -> { withProductOfStockAndChannel(client(), 5, channel, productWith5Items -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .plusQueryFilters(m -> m.id().isIn(asList(productWith5Items.getId(), productWith10Items.getId()))) .plusSort(m -> m.allVariants().availability().channels().channelId(channel.getId()).availableQuantity().asc()); assertEventually(() -> { final PagedSearchResult<ProductProjection> res = client().executeBlocking(request); assertThat(res.getResults()).hasSize(2); assertThat(res.getResults().get(0).getId()) .isEqualTo(productWith5Items.getId()); }); }); }); });
See the test code.
ChannelsProductVariantAvailabilitySortSearchModel<T> channels()