Search Criteria Interface for list filtering
Knowing how to do a proper list filtering to fetch the entities that match a certain lookup is essential for the effective use of getList
services across core Magento and possibly custom-coded API's. An example is fetching the list of customers registered within the last 24 hours for the latest added product.
Let's take a look back at our app/code/Foggyline/Slider/etc/webapi.xml
file, the bit where we defined the service method="getList"
. The service class is defined as Foggyline\Slider\Api\SlideRepositoryInterface
, which is defined as a preference for the Foggyline\Slider\Model\SlideRepository
class. Finally, within the SlideRepository
class, we have the actual getList
. Method getList
is defined as follows:
getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
We can see that the getList
method takes only one parameter, object instance, that complies with SearchCriteriaInterface
called $searchCriteria
.
What this means is we already...