Guest User

Untitled

a guest
Jan 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. // Store ID 2 - default currency EUR, base currency USD
  2. // $product is instance of MagentoCatalogModelProduct
  3. $priceInfo = $product->getPriceInfo();
  4. $price = $priceInfo->getPrice('regular_price')->getValue();
  5.  
  6. $helper->currencyConvert($price, 'EUR', 'USD');
  7.  
  8. public function convert($price, $toCurrency = null)
  9. {
  10. if ($toCurrency === null) {
  11. return $price;
  12. } elseif ($rate = $this->getRate($toCurrency)) {
  13. return $price * $rate;
  14. }
  15.  
  16. $basePrice = $product->getPrice();
  17. $currency = $currencyFactory->create()->load('EUR');
  18. $eurPrice = $currency->convert($basePrice, 'EUR');
  19.  
  20. $objectManager = MagentoFrameworkAppObjectManager::getInstance();
  21. $productId = 46;
  22. $product = $objectManager->create('MagentoCatalogModelProduct')->load(productId );
  23. $price = $product->getFinalPrice();
  24. $currency = $objectManager->create('MagentoDirectoryModelCurrency')->load('USD');
  25. echo $currency->convert($price,'EUR');
Add Comment
Please, Sign In to add comment