So today, we want to introduce you to the best solution to manage the product price and currency easily at each store view:
Writing is a part of my life and I’m living for it.

Highlight features:

What Is Magento 2 Store Base URL?

Magento 2 base urls
Magento 2 Multiple Store View Pricing by BSS

Run the following code:
Each Magento website has a base URL assigned to the storefront and another one assigned to the admin.
Table of Contents

  • Base URL: http://www.yourdomain.com/magento/
  • Secure Base URL: https://www.yourdomain.com/magento/
  • URL with IP address: http://###.###.###.###/magento/ or https://###.###.###.###/magento/

How To Get Magento 2 Store Base URL?

The standard base URL begins with HTTP, and the secure base URL begins with HTTPS.

  • Using the Magento core method
  • Using object manager

Using the Magento core method

We hope this blog is helpful and good luck to you!
We hope this blog is helpful and good luck to you!
It also enables you to choose the base currency for each store view and supports checking out with the base currency so your customers can purchase with their preferred currency.
There are two methods to get Magento 2 Store Base URL:
Magento uses variables to define internal links in relation to the base URL, thus you can move the whole store from one location to another without updating the link.
Let’s get started!

magento-2-multiple-store-view-pricing
For example, in the US store, you would want the product’s price to be displayed in USD, and in the France store, you would want the product’s price to be displayed in EUR.

<?php
namespace [Vendor][Module]Helper; use MagentoFrameworkAppHelperAbstractHelper;
use MagentoFrameworkAppHelperContext;
use MagentoStoreModelStoreManagerInterface; class Data extends AbstractHelper
{
protected $storeManager; public function __construct(
Context $context,
StoreManagerInterface $storeManager
)
{
$this->storeManager = $storeManager;
parent::__construct($context);
} public function getStoreManagerData()
{
$storeUrl = $this->storeManager->getStore()->getBaseUrl(); // get Store Url without index.php
$storeUrl = $this->storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_WEB); // get Link Url of store
$storeLinkUrl = $this->storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_DIRECT_LINK); // get media Base Url
$storeMediaUrl = $this->storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA); // get Static content Url
$storeStaticUrl = $this->storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_STATIC);
}
}

Using object manager

magento-2-multiple-store-view-pricing
In this article, we have shown 2 simple methods to get your Magento 2 store base URL.
Magento 2 base urls

  • Set up different prices, special prices and tier prices for a product per store view 
  • Set up base currency per store view
  • Customers checkout with the base currency of their store view conveniently
  • Set up various special prices for a product per store view 

Conclusion

BSS Commerce is one of the leading Magento extension providers and web development services in the world. With experienced and certified Magento developers, we commit to bringing high-quality products and services to optimize your business effectively. Furthermore, we offer FREE Installation – FREE 1-year Support and FREE Lifetime Update for every Magento extension.
This extension allows you to set any price type for a product, including regular price, special price and tier price. And these prices can be different among your store views for the same product.
In this article, we will show you how to get your Magento 2 store base URL using very simple code.
This module allows you to set up Minimum Order Amount, Shipping Cost and Custom Options Price for each store view, too.


CONTACT NOW to let us know your problems. We are willing to support you every time.

Similar Posts