How to use curl in Magento 2

We will be learning here, how one can use curl in Magento 2. At first, you need to create an instance of “\Magento\Framework\HTTP\Client\Curl” in the Constructor as shown below: /** * @var \Magento\Framework\HTTP\Client\Curl */ protected $_curl; /** * Data constructor. * * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\HTTP\Client\Curl $curl */ public function…
Read More

How to get category by url key in Magento 2

  Here is the sample code to get category by category url key. categoryFactory = $categoryFactory; } public function getCategory($urlKey, $parentCatId) { $categories = $this–>categoryFactory->create()–>getCollection() –>addAttributeToFilter(‘url_key’, $urlKey) –>addAttributeToSelect([‘entity_id’]); return $categories; } } Now you can get category by using function getCategory($urlKey) $urlKey = ‘cloths’; $category = $this–>getCategory($urlKey); print_r($category->getData()); Multiple categories may…
Read More