如何在Magento中获取商店信息? [英] How to get store information in Magento?

查看:55
本文介绍了如何在Magento中获取商店信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Magento中,如何获取有效的商店信息,例如商店名称,行号等?

In Magento, how can I get active store information, like store name, line number, etc?

推荐答案

要从Magento的任何地方获取有关当前商店的信息,请使用:

To get information about the current store from anywhere in Magento, use:

<?php
$store = Mage::app()->getStore();

这将为您提供一个Mage_Core_Model_Store对象,其中包含您需要的一些信息:

This will give you a Mage_Core_Model_Store object, which has some of the information you need:

<?php
$name = $store->getName();


对于您关于行号的其他问题,我不确定您的意思.如果您想知道代码所在的行号(例如,用于错误处理),请尝试:


As for your other question about line number, I'm not sure what you mean. If you mean that you want to know what line number in the code you are on (for error handling, for instance), try:

<?php
$line      = __LINE__;
$file      = __FILE__;
$class     = __CLASS__;
$method    = __METHOD__;
$namespace = __NAMESPACE__;

这篇关于如何在Magento中获取商店信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆