TransWikia.com

Multi website - how to use media url in phtml file

Magento Asked on November 8, 2021

i have setup multi website in magento 2.3.4 on single Domain with setting – Add Store Code to Urls

enter image description here

my website URLs are like below now
1: example.com/in
2: example.com/us

i want to call images from media folder , earlier i use below code that is not working after multi store

Earlier code : getBaseUrl(); ?>media/abc.png

Issue : after muti store setup my image URL becomes like example.com/us/media/abc.png and this causes issue with images ,

Please help way to fix it

One Answer

try to get the base url based on the store, something like,

* @var MagentoStoreModelStoreManagerInterface $this->_storeManager
*/

$this->_storeManager->getStore()->getBaseUrl();

In database you should have a base url for each store ID correct? In core_config_data table, in column path search this web/secure/base_url and check if appears 2 results with different scopes. Hope it helps :D

Answered by Rui Silva on November 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP