I keep reading about the use of [interface]::getList within Magento 2 and how it's the preferred method for fetching records. For example:
namespace Magento\Customer\Api;
interface CustomerRepositoryInterface
{
/**
* Retrieve customers which match a specified criteria.
*
* This call returns an array of objects, but detailed information about each object’s attributes might not be
* included. See https://devdocs.magento.com/codelinks/attributes.html#CustomerRepositoryInterface to determine
* which call to use to get detailed information about all attributes for an object.
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \Magento\Customer\Api\Data\CustomerSearchResultsInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
}
Can anyone explain the how to use it and why it's the preferred method?