4
votes

I have several websites using different currencies on each store view. The base currency (default) is set to GBP. If I add a fixed price to a custom option the currency is converted according to store currency which is fine.

The problem starts when I want to update other values afterwards as it keeps converting the price. For example, Let’s say I have a product on Store View 1 with a custom option that adds 100 GBP for a blue color option. The same product will appear on Store View 2 with a custom option that adds 120 EUR for a blue color option, according to the correct currency conversion.

If I change any value on Store View 2, for example, changing the name of the product or adding an image, a change that doesn’t involve the price or the custom options, and than I save the change, it will continue to convert the price of the custom option. If it was 120 EUR it will refer to it as if it is a new value of 120 GBP and convert it to 143.5 EUR and so on. If I’ll click save again it will convert it again to 171.5 EUR and so on.

This happens because Magento refers to the custom options added price as a new value that needs to be converted.

Any idea how can I solve this as every time I change a value of a product it changes the custom options price?

1
SET 120 EUR in Store View 2 from admin panelhimansu
It keeps converting to GBPido

1 Answers

1
votes

I know that this is quite old question, but this bug still occurs (even in Magento 1.9) so maybe my answer will help somebody.

You have to overwrite Mage_Catalog_Model_Resource_Product_Option_Value class.

First add this method:

protected function checkIfPriceHasNotBeenChanged($object, $storeId)
{
    $newPrice = (float)sprintf('%F', $object->getPrice());
    $priceTable = $this->getTable('catalog/product_option_type_price');

    $select = $this->_getReadAdapter()->select()
        ->from($priceTable, 'price')
        ->where('option_type_id = ?', (int)$object->getId())
        ->where('store_id = ?', $storeId);
    $oldPrice = $this->_getReadAdapter()->fetchOne($select);

    return $newPrice == $oldPrice;
}

Then use it in _saveValuePrices method:

if ($object->getStoreId() != '0' && $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE
        && !$object->getData('scope', 'price')) {

        $baseCurrency = Mage::app()->getBaseCurrencyCode();

        $storeIds = Mage::app()->getStore($object->getStoreId())
            ->getWebsite()
            ->getStoreIds();

        if (is_array($storeIds)) {
            foreach ($storeIds as $storeId) {
                if ($priceType == 'fixed') {

                    if ($this->checkIfPriceHasNotBeenChanged($object, $storeId)) {
                        continue;
                    }
(...)