How to get Product Canonical Url by id Programmatically Magento 2?

Get Product Canonical URL in Magento using product id to see your current store product page Canonical URL.

Fetch Product Object by the id and use the method getUrlInStore() to retrieve URL.

Check given code to retrieve canonical URL, Continue reading “How to get Product Canonical Url by id Programmatically Magento 2?”

How to check cookie restriction mode enabled programmatically Magento 2?

You can check the cookie restriction mode value enabled or not for the current store using Magento 2.

Cookie Restriction mode XML config path is ‘web/cookie/cookie_restriction’ and you can check the value for the specified store using Helper class.

Magento\Cookie\Helper\Cookie class contains public function isCookieRestrictionModeEnabled() to verify Mode is enabled for the current store. Continue reading “How to check cookie restriction mode enabled programmatically Magento 2?”

How to get Sub Category details by parent id Magento 2?

Get Sub Category (Child category) Collection details by the Parent Category id in Magento 2.

Using Parent Category Id, You can explore all the children category with deep level Or You can retrieve id by Current Category

When you check the Magento Open source sample data, You can see Men Category has direct two-child categories, Tops, and Bottoms at level 3 and both have other subcategories (Jacket, Tees, Pants, Shorts, etc) at level 4. Continue reading “How to get Sub Category details by parent id Magento 2?”