How to get customer id from API header bearer token Magento 2?

You can fetch the customer ID from the Web API Header Authorization Token in Magento 2.

At the development time of a custom module, you are required to fetch the customer ID from the Bearer token passed in the Header.

You can just follow the given code snippet to fetch the customer ID from the current payload. Continue reading “How to get customer id from API header bearer token Magento 2?”

How to use insertFromSelect query in database Magento 2 with best practice?

You can use INSERT IGNORE INTO mysql query with the help of insertFromSelect() method in Magento 2 with use of magento best standard in your module.

Lets we have a query that use the insertFromSelect method to run a query.

Raw SQL Query to add an entry to the small_image attribute from the image attribute value. Continue reading “How to use insertFromSelect query in database Magento 2 with best practice?”

How to check is database table exists or not by Magento 2?

You can verify the given database table available in the database with the help of isTableExists() method by use of Magento\Framework\App\ResourceConnection class.

This method is useful when you are dealing with a database query and want to run your query on the safe side to check whether the first given table exists or not before firing the SQL query. Continue reading “How to check is database table exists or not by Magento 2?”