Magento 2: Get Product collection filter using Service contract.

When you are looking for a product collection filter in Magento 2, the first thing in your mind come to go with the ProductFactory approach.

With ProductFactory way, When you do use a Collection, use a Factory class to instantiate the Collection, as the getCollection() method is deprecated. Continue reading “Magento 2: Get Product collection filter using Service contract.”

How to delete cookie in Magento 2?

Magento 2, You can delete the cookie using Magento’s Own Magento\Framework\Stdlib\CookieManagerInterface interface class.

You can delete cookie using deleteCookie() function from CookieManagerInterface Interface. Continue reading “How to delete cookie in Magento 2?”

How to set and get cookie in Magento 2?

Magento 2 You can add/set cookies and get/retrieve the cookie using Magento\Framework\Stdlib\CookieManagerInterface Interface.

By default, You can set the cookie using $_COOKIE with native PHP.

When you are following the coding standard in Magento 2, PHPMd displays the error for $_COOKIE is discouraged in Magento 2. Continue reading “How to set and get cookie in Magento 2?”