如何获得安装magento的基本网址?

时间:2014-09-12 11:36:08

标签: php magento base-url

我需要安装的基本网址,因为我必须将参数作为参数发送到中间付款,并且当它有子域名时只需更改基本网址或子网站设置子网站设置url到index.php就会出错添加路径< / p>

所以我需要下面这样的东西只选择已经在madroes Mage Magento中的对象

<?php
    $resource = Mage::getSingleton('core/resource');
    $readConnection = $resource->getConnection('core_read');
    $query = "SELECT value FROM  core_config_data WHERE scope = 'default' and path = 'web/unsecure/base_url'";  
    $results = $readConnection->fetchAll($query);

    print_r($results);

?>

返回

Array ( [0] => Array ( [value] => http://url of install/ ) ) 

3 个答案:

答案 0 :(得分:2)

$storeId = 0; // default, scope = default return base instalation
echo Mage::getStoreConfig('web/unsecure/base_url', $storeId);

答案 1 :(得分:-1)

您需要Mage::getUrl而不是仅仅获取基本域,它可以用来一次性获取完成的URL。

Mage::getUrl('path/to/notification', array('_store' => 'admin'));

答案 2 :(得分:-1)

<?php echo Mage::app()->getStore()->getBaseUrl(); ?>
相关问题