Magento – Base currency is CAD, but need to see USD prices in Magento Admin

magento-1.7magento-1.8magento-1.9

My base prices are in CAD (Canadian Dollars), I am trying to create an attribute which will show converted USD prices in the Backend. It must be an attribute, because I will need that converted USD price attribute to create Google Feeds.

So far, converted USD prices are only visible on the Fronend.

Please help guys! I would very much appreciate it.

Thank you in advance!

Best Answer

That is solution with new attribute and backend_model that I mentioned in comments above:

Create new attribute first:

$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'price_usd', array(
    'type'                       => 'decimal',
    'label'                      => 'USD Price',
    'input'                      => 'text',
    'backend'                    => 'yourmodule/product_attribute_backend_usdprice',
    'global'                     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
    'required'                   => false,
    'searchable'                 => false,
    'filterable'                 => false,
    'comparable'                 => false,
    'is_configurable'            => false,
   'group'                      => 'Price'
));

Then create class which represents model yourmodule/product_attribute_backend_usdprice;

The content is like this:

class Your_Module_Model_Product_Attribute_Backend_Usdprice extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
{
    /**
     * Before save method
     *
     * @param Varien_Object $object
     *
     * @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
     */
    public function beforeSave($object)
    {
        $attrCode = $this->getAttribute()->getAttributeCode();
        $basePrice = $object->getData('price');

        $value = Mage::helper('directory')->currencyConvert($basePrice, Mage::app()->getStore()->getDefaultCurrencyCode(), 'USD');
        $object->setData($attrCode, $value);

        return $this;
    }
}

Make sure that Mage::app()->getStore()->getDefaultCurrencyCode() returns CAD value.

Hope it helps.

Related Topic