public function save($currencyId) { if (!$this->isPostRequest()) { exit; } try { $exchangeRate = $this->param('exchangeRate'); $exchangeRate['currency'] = $currencyId; CurrencyModel::getInstance()->saveExchangeRate($exchangeRate); messages::add('Currency_Saved', 1, 'success'); $this->redirectBack(); } catch (\Exception $e) { messages::add('Error', 1, 'error'); $this->redirectBack(); } }
private function prepareForSaving($product) { $resProduct = $product; $resProduct['priority'] = intval($product['priority']); $resProduct['priceUsd'] = !empty($product['priceUsd']) ? str_replace(',', '.', $product['priceUsd']) : 0; if (empty($resProduct['priceByr'])) { $resProduct['priceByr'] = CurrencyModel::getInstance()->convertWithRounding($resProduct['priceUsd']); } return $resProduct; }