Magento 2 – How to get current Store ID Programmatically?

Magento 2 - How to get current Store ID Programmatically

Hello Devs,

During development, You may need to get some store-related information programmatically.

We can fetch information such as

  • Get Current Store
  • Get Store Data of the current store
  • Get Current Store ID
  • Get another Store by specifying the store ID
  • Get the Current Store Name
  • Get Current Store Status
  • Get a Custom page URL / Build Store-Specific URLs
  • Get Current Website ID
  • Get Current URL

The above information can be fetched easily in Magento using Magento’s Magento\Store\Model\StoreManagerInterface class.

Let’s see the below example for different cases :

Isn’t it easy? See related blogs like this.

Magento 2: How to get all websites list programmatically?

Magento 2: How to get all stores list programmatically

Add Yes/No Attribute in Magento 2 programmatically

Thank you !!

Leave a Reply

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