Magento-2 we would like to filter the products from REST API
I have filtered product by price in the frontend please check the result in the below screenshot
(24-MB02 price and special price we set at admin end)
Screenshot:-
But API Level:-
the same product 24-MB02 is missing
Api Url:- /rest/V1/products/
http://10.0.0.55/ma221/rest/V1/products/?searchCriteria[filterGroups][0][filters][0][field]=category_id&searchCriteria[filterGroups][0][filters][0][value]=4&searchCriteriafilterGroups[filters][0][field]=price&searchCriteriafilterGroups[filters][0][value]=40&searchCriteriafilterGroups[filters][0][condition_type]=gteq&searchCriteriafilterGroups[filters][0][field]=price&searchCriteriafilterGroups[filters][0][value]=50&searchCriteriafilterGroups[filters][0][condition_type]=lteq
But result we are getting 4 products
output:-
Please help on this. Thanks. How to achieve this?
/vendor/magento/module-catalog/Model/ProductRepository.php
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
{
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
$collection = $this->collectionFactory->create();
$this->extensionAttributesJoinProcessor->process($collection);
$collection->addAttributeToSelect('*');
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
$this->collectionProcessor->process($searchCriteria, $collection);
$collection->load();
$collection->addCategoryIds();
$searchResult = $this->searchResultsFactory->create();
$searchResult->setSearchCriteria($searchCriteria);
$searchResult->setItems($collection->getItems());
$searchResult->setTotalCount($collection->getSize());
foreach ($collection->getItems() as $product) {
$this->cacheProduct(
$this->getCacheKey(
[
false,
$product->hasData(\Magento\Catalog\Model\Product::STORE_ID) ? $product->getStoreId() : null
]
),
$product
);
}
return $searchResult;
}