An Adobe Commerce developer wants to generate a list of products using ProductRepositoryinterface and search for products using a supplier_id filter for data that is stored in a standalone table (It. not in an EAV attribute).
Keeping maintainability in mind, how can the developer add the supplier ID to the search?
Select an option, then click Submit answer.
-
○
Add a custom filter to the virtual type
-
○
Megento\Catalog\model\Api\SearchCriteria\CollectionProfessor\ProductFilterProcessor for supplier_id field. In the custom filter, apply the needed join and filter to the passed $collection.
-
○
Write a before plugin on \Magento \Cotalog\Model\ProductRepository: getlist() and register the search criteria passed. Write an event observer to listen for the event catalog_product_collection_load_before - Iterate through the registered search criteria, and if found, apply the needed join and filter to the event's $collection .
-
○
Write a before plugin on Magento\Fremework\api\SearchCriteria\CollectionProcessorinterface::process() . Iterate through the $searchCriteria provided for supplier_id , and if found, apply the needed join and filler to the passed $collection .