How to Get Current Store ID in Magento 2

Thank you.
I would be happy to answer.
If you have questions regarding this post, feel free to ask in the comment section below.
Thank you for subscribing.
Something went wrong.
Never miss Magento tips, tricks, tutorials, and news.

Method to Get Current Store ID in Magento 2

  • Using Block

You can get store ID by calling the block function in your phtml file.

  • Using Object Manager

That’s it.
In order to work with more than one store from a single administration, the store owner has to set up multi store in Magento 2. While working with a multi-store environment, the need often arrives to get current store id in Magento 2.
Related Post
Hence, Magento 2 allows having multi-stores to serve your customers with a shopping platform that is comfortable to them.
Check out the below code to do so using block and object manager.
E-commerce has changed the way people do business and shop. With online shopping, a customer from France can make a purchase from a store in India! However, as the customer base increases, the store owners try to offer a shopping platform that is compatible with their shoppers’ local language, currency, etc.

Get Weekly Updates

Especially, when the store owner needs customization based on the store. For example, store A has different currency and product rates than store B.

Before implementing any such condition-based customization, you first have to get the store ID, and then implement the logic such as if the store id is equal to one, then don’t show a popup of discounted products or generate a store-specific CSV, otherwise do.
Do consider sharing this post with Magento Community via social media.

/**/

/*.mfp-bg{background:#000000d4}
/*]]>*/

/*.mfp-bg.mfp-ready{opacity:.6}
/*]]>*/

(based on 0 Reviews)