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

Get CMS Block Collection in Magento 2.

You can get all the CMS Static Blocks collection in Magento 2 by calling interface, Magento\Cms\Api\BlockRepositoryInterface.

Magento\Cms\Api\BlockRepositoryInterface used for getting CMS Static Blocks related data in Magento 2.

BlockRepositoryInterface is used when you need to fetch a collection of CMS Static blocks or get specific CMS static block data. You can get Specific Blocks data by Identifier using  Get Cms Blocks data by an identifier.

Continue reading “Get CMS Block Collection in Magento 2.”