Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Store ID 2 - default currency EUR, base currency USD
- // $product is instance of MagentoCatalogModelProduct
- $priceInfo = $product->getPriceInfo();
- $price = $priceInfo->getPrice('regular_price')->getValue();
- $helper->currencyConvert($price, 'EUR', 'USD');
- public function convert($price, $toCurrency = null)
- {
- if ($toCurrency === null) {
- return $price;
- } elseif ($rate = $this->getRate($toCurrency)) {
- return $price * $rate;
- }
- $basePrice = $product->getPrice();
- $currency = $currencyFactory->create()->load('EUR');
- $eurPrice = $currency->convert($basePrice, 'EUR');
- $objectManager = MagentoFrameworkAppObjectManager::getInstance();
- $productId = 46;
- $product = $objectManager->create('MagentoCatalogModelProduct')->load(productId );
- $price = $product->getFinalPrice();
- $currency = $objectManager->create('MagentoDirectoryModelCurrency')->load('USD');
- echo $currency->convert($price,'EUR');
Add Comment
Please, Sign In to add comment