Jump to content

Multicurrency store wrong attributes calculation


Recommended Posts

I have a multy currency store with products that have many combination and price increasing according to the option chosen by the customer.

 

Currency available are PLN(Default) USD and EUR 

 

As the default currency for store is PLN, the attributes value n the combination are settled in this currency. 

 

The main problem is that in the product pages having another currency than the default, while selecting combination for the product the price is getting increased by the amount reported in the default currency.

 

It would be less problematic if the value would be lower than the real but in the case the currency relationship is 4 to 1 a theoretical increase of 10 Eur result in a 42 Eur surcharge on the shown price.

 

I need some help, tried to install and uninstall all the module that are not native do not fix the issue,

 

Any advice is welcome as I have no idea what to do more.

 

 

 

 

 

Link to comment
Share on other sites

I also still need help about this problem.

But it seems that nobody want to help.

 

Anyway just for the record, also the fresh installation of prestashop 1.606 without any additional module has this problem.

 

Maybe it is not a problem, just a bug!!

Link to comment
Share on other sites

Other problem found with multicurrency shop.

 

In backoffice orders are converted in the default currency but the currency mark remain. 

 

???

 

They are releasing version after version, but it seems there is not one really working yet!

 

plenty of bugs!!

Link to comment
Share on other sites

I have similar problem. Although when showing base product prices the currency is converted correctly when we make combinations of product attributes prestashop returns very strange conversion rates. I don't see other option to put multiple currencies with product combinations than using currency exchange so i have problem now :(

Link to comment
Share on other sites

  • 1 month later...

Hey! Any progress on this? I think of reporting this to the official bug tracker.

 

In my case, I have four currencies.

 

PLN default currency, products with combinations have different prices (bigger package=price increase).

 

For say small packaging, the price is 20pln. For big, 45.

 

Small is the default.

 

In SEK currency, small packaging, after conversion, shows up fine - about 45kr which is correct.

 

However, the big packaging shows for 65kr, which is some weird arbitrary number - it's neither the base price, nor price without tax, nor the increase in PLN by which the product is bumped on the big package attribute.

 

What gives? This is impossible to operate - I would end up selling under the purchase price, or with almost no gain!

 

Edit: hmm, looks like this issue is already addressed - look here: http://forge.prestashop.com/browse/PSCSX-2375

 

I added the fix mentioned by luis piel and it works as expected - my prices display correctly now, for all attributes, in all currencies.

 

Looks fixed!

Edited by imachine (see edit history)
Link to comment
Share on other sites

Hi All,

 

I was also facing this problem prestashop new release having some bug I hope prestashop team member should resolve these issue before they move for next version release. I don't when they will do . but I have got solution myself by overriding product controller.

 

Process

Methode first

--------------------------------------------------------------------------

Edit Product controller

 

Open file - controllers -> front- >ProductController.php

 

find  code near Line no 445

$combinations[$row['id_product_attribute']]['price'] = (float)$row['price'];

Replace With

$combinations[$row['id_product_attribute']]['price'] = (float)Tools::convertPrice($row['price'],Context::getContext()->currency);

Methode 2 By Overriding Product controller 

 

Go to location override\controllers\front\

 

Create New File name  ProductController.php

 

and Write code given below  

 

<?php


class ProductController extends ProductControllerCore {


    protected function assignAttributesGroups() {
        $colors = array();
        $groups = array();


        // @todo (RM) should only get groups and not all declination ?
        $attributes_groups = $this->product->getAttributesGroups($this->context->language->id);
        if (is_array($attributes_groups) && $attributes_groups) {
            $combination_images = $this->product->getCombinationImages($this->context->language->id);
            $combination_prices_set = array();
            foreach ($attributes_groups as $k => $row) {
                // Color management
                if (isset($row['is_color_group']) && $row['is_color_group'] && (isset($row['attribute_color']) && $row['attribute_color']) || (file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg'))) {
                    $colors[$row['id_attribute']]['value'] = $row['attribute_color'];
                    $colors[$row['id_attribute']]['name'] = $row['attribute_name'];
                    if (!isset($colors[$row['id_attribute']]['attributes_quantity']))
                        $colors[$row['id_attribute']]['attributes_quantity'] = 0;
                    $colors[$row['id_attribute']]['attributes_quantity'] += (int) $row['quantity'];
                }
                if (!isset($groups[$row['id_attribute_group']]))
                    $groups[$row['id_attribute_group']] = array(
                        'group_name' => $row['group_name'],
                        'name' => $row['public_group_name'],
                        'group_type' => $row['group_type'],
                        'default' => -1,
                    );


                $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
                if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1)
                    $groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute'];
                if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']]))
                    $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
                $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity'];




                $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
                $combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute'];
                $combinations[$row['id_product_attribute']]['price'] = (float)Tools::convertPrice($row['price'],Context::getContext()->currency);


                // Call getPriceStatic in order to set $combination_specific_price
                if (!isset($combination_prices_set[(int) $row['id_product_attribute']])) {
                    Product::getPriceStatic((int) $this->product->id, false, $row['id_product_attribute'], 6, null, false, true, 1, false, null, null, null, $combination_specific_price);
                    $combination_prices_set[(int) $row['id_product_attribute']] = true;
                    $combinations[$row['id_product_attribute']]['specific_price'] = $combination_specific_price;
                }
                $combinations[$row['id_product_attribute']]['ecotax'] = (float) $row['ecotax'];
                $combinations[$row['id_product_attribute']]['weight'] = (float) $row['weight'];
                $combinations[$row['id_product_attribute']]['quantity'] = (int) $row['quantity'];
                $combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
                $combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
                $combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
                if ($row['available_date'] != '0000-00-00') {
                    $combinations[$row['id_product_attribute']]['available_date'] = $row['available_date'];
                    $combinations[$row['id_product_attribute']]['date_formatted'] = Tools::displayDate($row['available_date']);
                } else
                    $combinations[$row['id_product_attribute']]['available_date'] = '';


                if (!isset($combination_images[$row['id_product_attribute']][0]['id_image']))
                    $combinations[$row['id_product_attribute']]['id_image'] = -1;
                else {
                    $combinations[$row['id_product_attribute']]['id_image'] = $id_image = (int) $combination_images[$row['id_product_attribute']][0]['id_image'];
                    if ($row['default_on']) {
                        if (isset($this->context->smarty->tpl_vars['cover']->value))
                            $current_cover = $this->context->smarty->tpl_vars['cover']->value;


                        if (is_array($combination_images[$row['id_product_attribute']])) {
                            foreach ($combination_images[$row['id_product_attribute']] as $tmp)
                                if ($tmp['id_image'] == $current_cover['id_image']) {
                                    $combinations[$row['id_product_attribute']]['id_image'] = $id_image = (int) $tmp['id_image'];
                                    break;
                                }
                        }


                        if ($id_image > 0) {
                            if (isset($this->context->smarty->tpl_vars['images']->value))
                                $product_images = $this->context->smarty->tpl_vars['images']->value;
                            if (isset($product_images) && is_array($product_images) && isset($product_images[$id_image])) {
                                $product_images[$id_image]['cover'] = 1;
                                $this->context->smarty->assign('mainImage', $product_images[$id_image]);
                                if (count($product_images))
                                    $this->context->smarty->assign('images', $product_images);
                            }
                            if (isset($this->context->smarty->tpl_vars['cover']->value))
                                $cover = $this->context->smarty->tpl_vars['cover']->value;
                            if (isset($cover) && is_array($cover) && isset($product_images) && is_array($product_images)) {
                                $product_images[$cover['id_image']]['cover'] = 0;
                                if (isset($product_images[$id_image]))
                                    $cover = $product_images[$id_image];
                                $cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id . '-' . $id_image) : (int) $id_image);
                                $cover['id_image_only'] = (int) $id_image;
                                $this->context->smarty->assign('cover', $cover);
                            }
                        }
                    }
                }
            }


            // wash attributes list (if some attributes are unavailables and if allowed to wash it)
            if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) {
                foreach ($groups as &$group)
                    foreach ($group['attributes_quantity'] as $key => &$quantity)
                        if ($quantity <= 0)
                            unset($group['attributes'][$key]);


                foreach ($colors as $key => $color)
                    if ($color['attributes_quantity'] <= 0)
                        unset($colors[$key]);
            }
            foreach ($combinations as $id_product_attribute => $comb) {
                $attribute_list = '';
                foreach ($comb['attributes'] as $id_attribute)
                    $attribute_list .= '\'' . (int) $id_attribute . '\',';
                $attribute_list = rtrim($attribute_list, ',');
                $combinations[$id_product_attribute]['list'] = $attribute_list;
            }


            $this->context->smarty->assign(array(
                'groups' => $groups,
                'colors' => (count($colors)) ? $colors : false,
                'combinations' => $combinations,
                'combinationImages' => $combination_images
            ));
        }
    }


}
?>

or Download ProductController.php and place in override folder

 

 

ProductController.php

  • Like 5
Link to comment
Share on other sites

×
×
  • Create New...