public function createcountriesAction()
 {
     $language = $this->_getParam("language");
     $locale = new Zend_Locale($language);
     $regions = Zend_Locale::getTranslationList('RegionToTerritory');
     $countryGroup = array();
     foreach ($regions as $region => $countriesString) {
         $countries = explode(' ', $countriesString);
         foreach ($countries as $country) {
             $countryGroup[$country] = $locale->getTranslation($region, 'territory', $locale);
         }
     }
     $countries = Country::getCountries();
     foreach ($countries as $iso => $name) {
         $currencyCode = Country::getCurrencyCodeForCountry($iso);
         $currencyDetail = Country::getCurrencyDetail($currencyCode);
         if (!$currencyCode || !$currencyDetail) {
             continue;
         }
         $currencyName = $currencyDetail['name'];
         $currencySymbol = $currencyDetail['symbol'];
         $currencyIsoNumber = $currencyDetail['isocode'];
         //Check if currency Object already exists
         $currencyObject = Model\Currency::getByName($currencyName);
         if (!$currencyObject instanceof Model\Currency) {
             $currencyObject = new Model\Currency();
             $currencyObject->setSymbol($currencySymbol);
             $currencyObject->setNumericIsoCode($currencyIsoNumber);
             $currencyObject->setIsoCode($currencyCode);
             $currencyObject->setExchangeRate(1);
         }
         $currencyObject->setName($currencyName);
         $currencyObject->save();
         //Check if country Object already exists
         $countryObject = Model\Country::getByIsoCode($iso);
         if (!$countryObject instanceof Model\Country) {
             $countryObject = new Model\Country();
         }
         $countryObject->setName($name);
         $countryObject->setIsoCode($iso);
         $countryObject->setActive(false);
         $countryObject->setCurrency($currencyObject);
         $countryObject->save();
     }
     $this->_helper->json(array("success" => true));
 }
 public function addAction()
 {
     $name = $this->getParam("name");
     if (strlen($name) <= 0) {
         $this->helper->json(array("success" => false, "message" => $this->getTranslator()->translate("Name must be set")));
     } else {
         $currency = new Currency();
         $currency->setName($name);
         $currency->save();
         $this->_helper->json(array("success" => true, "currency" => $currency));
     }
 }