AD0-E716 · Question #37
An Adobe Commerce developer wants to generate a list of products using ProductRepositorylnterf ace and search for products using a supplier_id filter for data that is stored in a standalone table…
The correct answer is B. Add a CUStOm filter to the Virtual type. The developer can add a custom filter to the virtual type Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\ProductFilterProce5sor for supplier_id field. In the custom filter, the developer can apply the needed join and filter to the passed $collection. This is the…
Question
An Adobe Commerce developer wants to generate a list of products using ProductRepositorylnterf ace and search for products using a supplier_id filter for data that is stored in a standalone table (i.e., not in an EAV attribute). Keeping maintainability in mind, how can the developer add the supplier ID to the search?
Options
- AWrite a before plugin on \Hagento\catalogVtodel\ProductRepository: :geti_ist() and register the
- BAdd a CUStOm filter to the Virtual type
- CWrite a before plugin On \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface:
How the community answered
(25 responses)- A16% (4)
- B56% (14)
- C28% (7)
Explanation
The developer can add a custom filter to the virtual type Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\ProductFilterProce5sor for supplier_id field. In the custom filter, the developer can apply the needed join and filter to the passed $collection. This is the recommended way to extend the search criteria for products using dependency injection and plugins. Verified Reference: [Magento 2.4 DevDocs] [Magento Stack
Topics
Community Discussion
No community discussion yet for this question.