-2
我有一个基本网址,我想从baseUrl
获得storeId
。
我怎样才能得到这个?如何使用magento中的基本网址获取商店编号
我的代码:
$baseUrl ="http://marketplace.computenext.com";
$storeId = "";
我需要的ID存储在$storeId
变量。
我有一个基本网址,我想从baseUrl
获得storeId
。
我怎样才能得到这个?如何使用magento中的基本网址获取商店编号
我的代码:
$baseUrl ="http://marketplace.computenext.com";
$storeId = "";
我需要的ID存储在$storeId
变量。
试试这个,
// Gets the current store's details
$store = Mage::app()->getStore();
// Gets the current store's id
$storeId = Mage::app()->getStore()->getStoreId();
这样你就可以收到了第一家专卖店(ID)与所需的网址:
<?php
require_once 'app/Mage.php';
Mage::app("admin");
$stores = Mage::getModel('core/store')->getCollection()->getItems();
$baseUrl = 'http://your.url.here.com/';
$searchableStoreId = null;
foreach ($stores as $storeId => $store) {
$currentStoreUnsecureUrl = Mage::getStoreConfig('web/unsecure/base_url', $storeId);
$currentStoreSecureUrl = Mage::getStoreConfig('web/secure/base_url', $storeId);
if ($currentStoreUnsecureUrl == $baseUrl || $currentStoreSecureUrl == $baseUrl) {
$searchableStoreId = $storeId;
continue;
}
}
echo $searchableStoreId; // int store id here or NULL
Click here像这样的事情? – Mitch