2016-12-01 114 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