Magento2 – Get URL from Other Website in CMS Page/Page Builder

cms-pagespage-builder

I have two websites in my Magento site and I want to put the url from the other website in the footers by cms_page using page builder.

I know that i can get the base url using {{config path="web/secure/base_url"}} but there is a way to get the base url of the other website like that?

Thanks!

Best Answer

Using the following class Magento\Framework\App\Config\ScopeConfigInterface

You can access any config for any scope.

$config->getValue(
    'web/secure/base_url', 
    \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, 
    $websiteId
);

The scope can also be store for example.

Related Topic