Product price

All the products in my project are configurable. I managed to convert price using below code.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product1 = $objectManager->get('Magento\Framework\Registry')->registry('current_product');//get current product
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($product1->getId() );
$price = $product->getFinalPrice();
$currencysymbol = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
$currency2 = $currencysymbol->getStore()->getCurrentCurrencyCode();
$currency = $objectManager->create('Magento\Directory\Model\Currency')->load($currency2);
echo $price;
echo $currency2;

if($currency2 == 'SAR'){

    echo $currency->convert($price,'AED');
elseif($currency2 == 'AED'){
    echo $currency->convert($price,'SAR');

But by default when product options are selected the product price varies dynamically for a configurable product. In this situation how to pass the different products id's on different options selected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.