-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