Store Emulation in Magento 2

App Emulation in Magento 2

Magento is famous for is its capabilities to develop multi-store and multi-language web stores. Each store can be completely different from its fellow stores. Store Emulation helps developers to emulate any store programmatically.

Store emulation is also know as Area Emulation and App Emulation.

Suppose you want to send custom transactional e-mail for all stores at the same time as cronjob.

When a process run on backend for example cron jobs or email notifications, these processes work under admin store.

But suppose if you want to send transactional e-mail on store wise, then email template need grab from store view.

You can enable App Emulation and perform this action.

Let’s check an quick example which demonstrates store emulation cron running for specific store.

I’m supposing that you have created your module or if not check this tutorial for create a custom module.

Let’s get started !!

Magento has provided a class to do such things, \Magento\Store\Model\App\Emulation this class provides two methods:

An example of how we can use these methods to emulate the store environment :

This way you can emulate area in Magento 2. I hope you like the tutorial, Let me know if you have any query in the comment box or contact me.

Leave a Reply

Your email address will not be published. Required fields are marked *