How to apply custom conditions before get faceted data elastic search results Magento 2?

Apply custom conditions on faceted data elastic search collection before it returns field faceted data from the faceted search results in Magento 2.

From the Magento 2.4, Elasticsearch is the Primary search engine instead of Deprecated Mysql.

When you go to the Catalog search module, FullText collection class, you can check the getFacetedData() method to return the field with faceted search results. Using Before plugin, you can add custom conditions before final search results render on the page. Continue reading “How to apply custom conditions before get faceted data elastic search results Magento 2?”

How to get Image roles types from product programmatically Magento 2?

To Retrieve Media Images Roles type from the Product in Magento 2 is useful to know each image role whether its small_image, thumbnail, or swatch image.

When you create a product, you need to assigned roles based on its display position.

The Base Role will be displayed on the product detail page.
A small Role will be displayed on the category listing page.
The ThumbnailRole will be displayed on the Shopping Cart page.
Swatch imageRole will be displayed on the product swatches. Continue reading “How to get Image roles types from product programmatically Magento 2?”

How to use of wishlist_add_product event in Magento 2?

Wishlist adds product events that will be used to define data after a successful item added to the wishlist.

If you want to trigger something once product added to wishlist or do some action after item added to the wishlist, you need to define "wishlist_add_product" in your events.xml file.

Create Observer Class to handle your logic after adding items to the wishlist. In the observer file, You got Product, Wishlist, and Current Item object, based on that you can retrieve/modify your logic. Continue reading “How to use of wishlist_add_product event in Magento 2?”