• magento2 base url
    Magento 2

    How to get magento2 base url

    How to get magento2 base url. You want to get magento2 base url for your current store then you can follow this post. During your daily work, several time, you need to current store base url  and at Magento 1.x version you can get base url using Mage::getBaseUrl();As Magento2, do not used factory patterns, so the code like  Mage::getBaseUrl();  is not exist by which you can base URL.But at Magento2, you should use StoreManager object  and  using  $this->_storeManager->getStore()->getBaseUrl()  you can get base url. Magento2, use interface, injection of class, that you should  Inject. [crayon-5c17f00b0bd93380071666/] at Model, Resource model, Block, Helper classes for getting base url using below code: [crayon-5c17f00b0bd9a126903734/] But this…

  • Magento 2

    magento2 get base url and media url and static url

    magento2 get base url and media url and static url magento2 get base url and media url and static url. Whenever you are working on  magento2 then a lot of times you need to get base URL and media URL and static url. From this blog, you base url, media url, static content url in Magento2.Magento2 basically, use interface [crayon-5c17f00b0c36a755116712/] And this class have a function  Store()  which is provide store data. After that,  using getBaseUrl() over Store()  you can get base url  and also get Media URL. [crayon-5c17f00b0c370968934869/] Where $storeManager is the instance of Magento\Store\Model\StoreManagerInterface. If you want to get Base Url without Index.php then click here. For Getting Media Url Use Below code: [crayon-5c17f00b0c372461988478/] Get Static content Url [crayon-5c17f00b0c374431262231/] But I…