Get list of Layout XML called for a current page Magento 2.

You can get a list of called Layout XML for specific pages by Magento\Framework\App\View class.

Call getLayout() method from Magento\Framework\App\View.php class.

getLayout()->getUpdate()->getHandles() used for getting all the handles of a page.

You need to keep below code at the end of root index.php file to check the available layout XML files for a page. Continue reading “Get list of Layout XML called for a current page Magento 2.”

Display success and error messages using ManagerInterface Magento 2

Magento 2, You can show Success and Error Message Using Interface Magento\Framework\Message\ManagerInterface.

You can display success message Using addSuccessMessage( ) and display error message using addErrorMessage( ) function.

addError( ), addSuccess( ), addWarning( ) and addNotice( ) methods are deprecated.

Continue reading “Display success and error messages using ManagerInterface Magento 2”

How to get Base Url and Current Url Magento 2?

In Magento 2, You can get Base Url, Current Url, get Media URL, get static page URL and custom URL using Magento\Store\Model\StoreManagerInterface and Magento\Framework\UrlInterface Object.

Using StoreManager Object,
Create PHP file and Passed Dependency injection Magento\Store\Model\StoreManagerInterface, Continue reading “How to get Base Url and Current Url Magento 2?”