How to Add Custom Mass Action in Order Grid in Magento 2

Welcome back Magento Folks to my blog. In this article, I will show you how we can add new custom mass action to the order grid. The default Magento provides mass action like Cancel, Print, Delete, etc. We can easily add new mass action with UI components by two simple steps. Create sales_order_grid.xml in custom…

Continue Reading How to Add Custom Mass Action in Order Grid in Magento 2

Get admin URL in Magento 2

We can use \Magento\Backend\Helper\Data class to get Admin Url. /** * @var Magento\Backend\Helper\Data */ private $backendHelper; public function __construct( ... \Magento\Backend\Helper\Data $backendHelper ... ) { ... $this->backendHelper = $backendHelper; ... } public function getAdminUrl() { retrun $this->backendHelper->getHomePageUrl(); } You can get admin URL by getHomePageUrl() function of backend helper class Here you will get admin…

Continue Reading Get admin URL in Magento 2

How to check if the current area is frontend or backend?

Use Magento\Framework\App\State class to get the area code of the current page. I will show you how you can get the current area by object manager and with dependency injection. With ObjectManager: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $state = $objectManager->get('Magento\Framework\App\State'); echo $state->getAreaCode(); With Dependency Injection: protected $_state; public function __construct ( \Magento\Framework\App\State $state ) { $this->_state =…

Continue Reading How to check if the current area is frontend or backend?