Add Secret Key to URLs in Magento 2.

Magento is delivering superior security to all of their clients and has been actively investigating the root cause of the reported issue and try to fix for security issue found in the system.

To prevent CSRF attacks for Magento backend you need to enable Add Secret Key to URLs, Out of the box, Magento provides this feature as enabled.

To reduce potential CSRF attacks in Magento 2 do the following steps. Continue reading “Add Secret Key to URLs in Magento 2.”

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?”