在Magento中,如何获取活跃的店铺信息,如店铺名称、行号等?
发布于 2010-04-26 21:42:44
要从Magento中的任何位置获取有关当前商店的信息,请使用:
<?php
$store = Mage::app()->getStore();这将为您提供一个Mage_Core_Model_Store对象,其中包含您需要的一些信息:
<?php
$name = $store->getName();至于你的另一个关于行号的问题,我不太明白你的意思。如果您的意思是想知道代码中的行号(例如,用于错误处理),请尝试:
<?php
$line = __LINE__;
$file = __FILE__;
$class = __CLASS__;
$method = __METHOD__;
$namespace = __NAMESPACE__;发布于 2011-03-30 13:16:50
Get存储数据
Mage::app()->getStore();商店Id
Mage::app()->getStore()->getStoreId();存储代码
Mage::app()->getStore()->getCode();网站Id
Mage::app()->getStore()->getWebsiteId();应用商店名称
Mage::app()->getStore()->getName();商店前端名称(请参阅@Ben的答案)
Mage::app()->getStore()->getFrontendName();是Active
Mage::app()->getStore()->getIsActive();商店的主页URL
Mage::app()->getStore()->getHomeUrl();商店的当前页面URL
Mage::app()->getStore()->getCurrentUrl();在类Mage_Core_Model_Store中可以找到
所有这些函数
文件:app/code/core/Mage/Core/Model/Store.php
发布于 2013-02-17 04:05:04
这里有很好的答案。如果您正在寻找Magento配置中设置的默认视图"Store Name“:
Mage::app()->getStore()->getFrontendName()https://stackoverflow.com/questions/2713042
复制相似问题