Пример #1
0
 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;
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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();
 }
 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));
 }