protected function _upgradeZipCodeList() { $this->_streamOutput->writeln('Updating zip codes database…'); $count = $this->_count($this->_zipCodeListByCityAdded, 4); $item = 0; foreach ($this->_zipCodeListByCityAdded as $countryCode => $zipCodeListByRegionAdded) { foreach ($zipCodeListByRegionAdded as $regionCode => $zipCodeListByCityAdded) { foreach ($zipCodeListByCityAdded as $cityCode => $zipCodeListAdded) { $cityId = $this->_cityIdList[$cityCode]; $city = new CM_Model_Location(CM_Model_Location::LEVEL_CITY, $cityId); foreach ($zipCodeListAdded as $zipCode => $zipCodeData) { $zip = CM_Model_Location::createZip($city, $zipCodeData['name'], $zipCodeData['latitude'], $zipCodeData['longitude']); $zipCodeId = $zip->getId(); $maxMind = $zipCodeData['maxMind']; $this->_zipCodeIdListByMaxMind[$maxMind] = $zipCodeId; $this->_printProgressCounter(++$item, $count); } } } } unset($this->_zipCodeListByCityAdded); }
public function testCreateZip() { $country = CM_Model_Location::createCountry('Example Country', 'EC'); $state = CM_Model_Location::createState($country, 'Example State', 'ES'); $city = CM_Model_Location::createCity($state, 'Example City', 50, 100); $zip = CM_Model_Location::createZip($city, '12333', 50, 100); $this->assertSame($country->getId(), $zip->getId(CM_Model_Location::LEVEL_COUNTRY)); $this->assertSame($state->getId(), $zip->getId(CM_Model_Location::LEVEL_STATE)); $this->assertSame($city->getId(), $zip->getId(CM_Model_Location::LEVEL_CITY)); $this->assertSame('12333', $zip->getName()); $this->assertSame(array('lat' => (double) 50, 'lon' => (double) 100), $zip->getCoordinates()); }