Get list of stores using the zip/city in shipping address
I need to get the list of stores using the zip/c开发者_高级运维ity 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 ?
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.
精彩评论