需要使用商店名称的magento商店ID

时间:2014-09-17 11:14:47

标签: magento web store

我想使用商店名称作为搜索来获取Magento商店ID。

我尝试了以下代码,但失败了。

$vendortitle = $vendortitle . " Store";
$name = Mage::getModel('core/store')->load($vendortitle)->getStoreId();
echo "<br>Store Name> ". $name;

提前致谢。

1 个答案:

答案 0 :(得分:1)

你的意思是商店代码?如果是这样,试试这个:

echo Mage::app()->getStore()->getCode(); // gives 'default'
// then use the following to get the store id
echo Mage::app()->getStore('default')->getId();