使用送货地址中的邮政编码/城市获取商店列表

发布于 2024-10-06 02:51:14 字数 203 浏览 2 评论 0原文

我需要使用我们在送货地址中指定的邮政编码/城市获取商店列表 (在管理面板中

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

) 有没有什么方法可以查询 Magento 来获取具有特定 Zip/city 的商店列表?

I need to get the list of stores using the zip/city that we specify in the shipping address
( In Admin Panel

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

)
Is there any way to query Magento to get the list of stores with a particular Zip/city ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

困倦 2024-10-13 02:51:14

此选项与网站链接,但不与商店链接。获得网站后,您应该获得与该网站链接的所有商店。

有一个如何获得正确网站的示例。

<?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")';

如果对象的范围类型,您需要网站和scope_id - 对象的ID。

This option linked with website, but not with store. After you get website, you should get all stores linked with this website.

There is example how to get a proper website.

<?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";
}
?>

Other - you may get directly from database. But in database you do not have default data.

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

Where scope type of object, you need website and scope_id - id of object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文