【问题标题】:Check store_id Magento检查 store_id Magento
【发布时间】:2012-11-21 12:52:54
【问题描述】:

我想检查哪个商店 id 当前处于活动状态并显示某些东西是商店 id 例如 1

我现在的代码是这样的:

<?php if (Mage::getModel('core/store')->load($storeId) == 9): ?>
//code here
<?php endif; ?>

但它总是返回 if 代码,无论商店 id 是什么。我认为问题出在“==”检查中。谁能告诉我正确的语法是什么?

【问题讨论】:

  • Mage::getModel('core/store')->load($storeId) 你用这个获取商店ID?
  • 是的,$storeId 是这样定义的
  • $storeId = Mage::app()->getStore()->getId();
  • 检查下面添加的答案

标签: php magento


【解决方案1】:
<?php if (Mage::app()->getStore()->getStoreId() == 9): ?>

在你的情况下

【讨论】:

  • 谢谢,就是这个。虽然它没有';'在 getStoreId() 后面
【解决方案2】:

获取当前商店信息使用

 Mage::app()->getStore()->getStoreId();

这将解释更多

how to get store information in Magento?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-28
    • 1970-01-01
    相关资源
    最近更新 更多