0

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!

11
  • are you want to see usd all price in price field at frontend
    – Amit Bera
    Oct 28 '14 at 17:39
  • @AmitBera Front end Shows Base price in CAD, and if a customer wants to see USD price, they click conversion link. I want to see, or at least have an attribute in the backend for USD converted prices. Because generally, I do not see what the price for my products in the USD, until I go to the front-page and click convert USD prices.
    – philtak
    Oct 28 '14 at 17:44
  • can you just convert the price during creating Google Feed?
    – alex_b
    Oct 28 '14 at 17:45
  • @alex_b Its best to have an attribute set which will show/contain converted USD prices. Manually punching in USD prices in the feed is hard in my cases, and sometimes they may change. Let say I change base price CAD for a product and don't make manual change in the USD pricing in the data feed, google will show my previous manually inputted USD price.
    – philtak
    Oct 28 '14 at 17:48
  • But if you convert attribute price during creating the feed it always will be correctly set in all currencies. In order to just see how it will be converted into another price you can use that select in product grid i.imgur.com/9u4bg8R.png or you can change the store in Store Switcher on product edit page in the admin
    – alex_b
    Oct 28 '14 at 17:54
1

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.

16
  • Could you please tell where can I find these files to edit. ( I am not too mage savvy yet.)
    – philtak
    Oct 28 '14 at 22:09
  • Its new files. You should create your own module and put them to it
    – alex_b
    Oct 28 '14 at 22:14
  • Yes, but where to place the module once I create it ? app/design? where
    – philtak
    Oct 28 '14 at 22:29
  • There are tons of articles about it over the internet. Look at insync.co.in/creating-custom-module-magento
    – alex_b
    Oct 28 '14 at 22:32
  • I have created an module, based on the instruction you have provided and also this example magento.stackexchange.com/questions/14163/… I dont see "price_usd" attribute in the magento admin under Manage Attributes
    – philtak
    Oct 29 '14 at 0:43

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.