Get Customer Id by email Magento 2.

Magento 2 We can get Customer data by customer email id.

You can get the customer id, first name, last name, and other customer specific data by customer email id.

You need to call Magento\Customer\Api\CustomerRepositoryInterface Interface to fetch customer-related data.

We need to call CustomerRepositoryInterface in our class __construct() method. Continue reading “Get Customer Id by email Magento 2.”

How to read CSV data as array pairs in Magento 2?

You can Retrieve CSV file data as pairs by just calling the Magento\Framework\File\Csv class. A Csv.php class contains the getDataPairs() function to convert the first column as a key and the second column as the value in the array from the CSV file.

This article is helpful if you have a CSV file with only two columns and want to treat it as an array key-value pair.

Let’s assume your CSV file contains below value for the first column and a second column with comma-separated, Continue reading “How to read CSV data as array pairs in Magento 2?”

How to Check file is exists or not at specific location programmatically in Magento 2?

You can check any physical file is exist or not at a specific location in Magento directory by Magento\Framework\Filesystem\Driver\File class.

You can use Magento 2 native class to check file is exist or not instead of the core PHP method.

I have taken a Block file and create a function for check file is exist or not via constructor DI, Continue reading “How to Check file is exists or not at specific location programmatically in Magento 2?”