2017-03-23 146 views
0

我想在檢查存儲類型的Magento和運行查詢,如果商店EN別的另一個查詢,我有我下面的代碼,但它不工作:如何獲得magento商店?

$name = $store->getName(); 
    $connection = Mage::getSingleton('core/resource')->getConnection('core_read'); 
    if($name=='EN') 
    { 
    $sql= "SELECT * FROM directory_country_region_EN WHERE name='$region' "; 
    } 
else 
{ 
$sql = "SELECT * FROM directory_country_region_SU WHERE name='$region' "; } 

回答

0

試試這個:

$name = Mage::app()->getStore()->getCode(); 
$connection = Mage::getSingleton('core/resource')->getConnection('core_read'); 
    if($name=='EN') 
    { 
    $sql= "SELECT * FROM directory_country_region_EN WHERE name='$region' "; 
    } 
else 
{ 
$sql = "SELECT * FROM directory_country_region_SU WHERE name='$region' "; }