public function init()
 {
     parent::init();
     Plugin::getEventManager()->trigger('controller.init', $this);
     $this->view->setScriptPath(array_merge($this->view->getScriptPaths(), array(PIMCORE_WEBSITE_PATH . '/views/scripts/', PIMCORE_WEBSITE_PATH . '/views/layouts/', PIMCORE_WEBSITE_PATH . '/views/scripts/coreshop/')));
     $this->view->addHelperPath(CORESHOP_PATH . '/lib/CoreShop/View/Helper', 'CoreShop\\View\\Helper');
     $this->session = $this->view->session = Tool::getSession();
     /*
     if(!$this->session->country instanceof CoreShopCountry) {
         if($this->session->user instanceof \CoreShop\Plugin\User && count($this->session->user->getAddresses()) > 0)
         {
             $this->session->country = $this->session->user->getAddresses()->get(0)->getCountry();
         }
         else
             $this->session->country = Tool::getCountry();
     }
     */
     if ($this->getParam("currency")) {
         if (Currency::getById($this->getParam("currency")) instanceof Currency) {
             $this->session->currencyId = $this->getParam("currency");
         }
     }
     $this->view->country = Tool::getCountry();
     $this->enableLayout();
     $this->setLayout(Plugin::getLayout());
     $this->prepareCart();
     $this->view->isShop = true;
 }
 /**
  * Get the assets from database
  *
  * @return array
  */
 public function load()
 {
     $currencies = array();
     $currenciesData = $this->db->fetchAll("SELECT id FROM coreshop_currency" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($currenciesData as $currencyData) {
         if ($currency = Model\Currency::getById($currencyData["id"])) {
             $currencies[] = $currency;
         }
     }
     $this->model->setCurrencies($currencies);
     return $currencies;
 }
 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));
 }
 /**
  * Get current Currency by Country
  *
  * @return Currency|null
  * @throws \Exception
  */
 public static function getCurrency()
 {
     $session = self::getSession();
     if ($session->currencyId) {
         $currency = Currency::getById($session->currencyId);
         if ($currency instanceof Currency) {
             return $currency;
         }
     }
     return self::getCountry()->getCurrency();
 }
                <!-- Currency & Languages Starts -->
                    <div class="col-sm-4 col-xs-12">

                        <div class="pull-right">

                            <!-- Currency Starts -->
                            <div class="btn-group">
                                <button class="btn btn-link dropdown-toggle" data-toggle="dropdown">
                                    <?php 
echo $this->translate("Currency");
?>
                                    <i class="fa fa-caret-down"></i>
                                </button>
                                <ul class="pull-right dropdown-menu">
                                    <?php 
foreach (\CoreShop\Model\Currency::getAvailable() as $currency) {
    ?>
                                    <li><a tabindex="-1" href="<?php 
    echo $this->url(array("currency" => $currency->getId()));
    ?>
"><?php 
    echo $currency->getName();
    ?>
 </a></li>
                                    <?php 
}
?>
                                </ul>
                            </div>
                        <!-- Currency Ends -->
 public function removeAction()
 {
     $id = $this->getParam("id");
     $currency = Currency::getById($id);
     if ($currency instanceof Currency) {
         $currency->delete();
         $this->_helper->json(array("success" => true));
     }
     $this->_helper->json(array("success" => false));
 }