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