【问题标题】:How to get the base url where magento is installed?如何获取安装 magento 的基本 url?
【发布时间】:2014-11-06 13:55:48
【问题描述】:

我需要安装的基本 url,因为我必须作为参数发送给中介付款,并且当它具有子域时,只需更改基本 url 或子存储,子域将 url 设置为 index.php 错误添加路径

所以我需要像下面这样的东西,只在 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/ ) ) 

【问题讨论】:

    标签: php magento base-url


    【解决方案1】:

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

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

    【讨论】:

    • 不会采用默认商店,因为它也可以在子域上并且安装不会@clockworkgeek
    【解决方案2】:
    $storeId = 0; // default, scope = default return base instalation
    echo Mage::getStoreConfig('web/unsecure/base_url', $storeId);
    

    【讨论】:

    • Store id = 0 是没有sublojas、语言或网站的默认安装
    【解决方案3】:
    <?php echo Mage::app()->getStore()->getBaseUrl(); ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-24
      • 1970-01-01
      • 2015-01-21
      • 2015-01-15
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 2014-02-23
      相关资源
      最近更新 更多