2016-12-01 46 views

回答

0

試試這個,

// Gets the current store's details 
$store = Mage::app()->getStore(); 

// Gets the current store's id 
$storeId = Mage::app()->getStore()->getStoreId(); 
0

這樣你就可以收到了第一家專賣店(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 
相關問題