使用送货地址中的zip / city获取商店列表

时间:2010-12-06 12:29:32

标签: php magento

我需要使用我们在送货地址中指定的zip / city来获取商店列表 (在管理员面板中

System->Configuration->Shipping Settings(In Sales Tab left)->Origin.

) 有没有办法查询Magento获取具有特定邮编/城市的商店列表?

1 个答案:

答案 0 :(得分:1)

此选项与网站相关联,但与商店无关。获得网站后,您应该获得与本网站链接的所有商店。

有一个例子可以找到一个合适的网站。

<?php
$requriedCode = "90034";
$requiredCity = "Kyiv";

$output = array();
$websites = Mage::app()->getWebsites(true, true);
foreach ($websites as $code => $website) {
    $postcode = $website->getConfig('shipping/origin/postcode');
    $city = $website->getConfig('shipping/origin/city');
    if ($postcode == $requriedCode or $city == $requiredCity) {
        $output[$code] = $website;
    }
}

foreach ($output as $site) {
    echo $site->getCode()."\r\n";
}
?>

其他 - 您可以直接从数据库获取。但是在数据库中,您没有默认数据。

$sql = 'select * from core_config_data where (path="shipping/origin/postcode" and value="90034") or (path="shipping/origin/city" and value="Kyiv")';

在对象的范围类型中,您需要website和scope_id - 对象的id。

相关问题