Jump to content

Aktualizacia mien


shoper

Recommended Posts

Nevsimol som si kedy presne, no prestala mi fungovat aktualizacia mien. Aktualizacia sa sice tvari, ze prebehla uspesne (bez akychkolvek chybovych hlaseni), no kurzy su tam stare. Kde by mohla byt chyba, alebo kde by som nasiel subor s konfiguraciou odkial sa tie kurzy "tahaju"?

Link to comment
Share on other sites

Pardón za to, samozrejme. Postupoval som podľa tejto verzie:
- v súbore "currency.php" som na konci natvrdo nahradil nasledovné (pozor na všetky zátvorky)

Hi there again,

For the Prestashop version 1.3.6.0 like above:

WARNING: Use this only if your default currency is EUR.

Go to your "classes" folder on your root, and then open "currency.php". On line 188 you should have this (the original line I have commented it with // and above is my line):

   public function refreshCurrency($data, $isoCodeSource, $defaultCurrency)
   {
       if ($this->iso_code != $isoCodeSource)
       {
           /* Seeking for rate in feed */
//            foreach ($data->currency AS $obj)
           foreach ($data->Cube->Cube->Cube AS $obj)
//                if ($this->iso_code == strval($obj['iso_code']))
               if ($this->iso_code == strval($obj['currency']))
                   $this->conversion_rate = round(floatval($obj['rate']) /  $defaultCurrency->conversion_rate, 6);
       }
       else
       {
           /* If currency is like isoCodeSource, setting it to default conversion rate */
           $this->conversion_rate = round(1 / floatval($defaultCurrency->conversion_rate), 6);
       }
       $this->update();
   }

   static public function refreshCurrenciesGetDefault($data, $isoCodeSource, $idCurrency)
   {
       $defaultCurrency = new Currency($idCurrency);

       /* Change defaultCurrency rate if not as currency of feed source */
       if ($defaultCurrency->iso_code != $isoCodeSource)
//            foreach ($data->currency AS $obj)
           foreach ($data->Cube->Cube->Cube AS $obj)
//                if ($defaultCurrency->iso_code == strval($obj['iso_code']))
               if ($defaultCurrency->iso_code == strval($obj['currency']))
                   $defaultCurrency->conversion_rate = round(floatval($obj['rate']), 6);
       return $defaultCurrency;
   }

   static public function refreshCurrencies()
   {
//        if (!$feed = @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml'))
       if (!$feed = @simplexml_load_file('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'))
           return Tools::displayError('Cannot parse feed!');
       if (!$defaultCurrency = intval(Configuration::get('PS_CURRENCY_DEFAULT')))
           return Tools::displayError('No default currency!');
//        $isoCodeSource = strval($feed->source['iso_code']);
       $isoCodeSource = 'EUR';
       $currencies = self::getCurrencies(true);
//        $defaultCurrency = self::refreshCurrenciesGetDefault($feed->list, $isoCodeSource, $defaultCurrency);
       $defaultCurrency = self::refreshCurrenciesGetDefault($feed, $isoCodeSource, $defaultCurrency);
       foreach ($currencies as $currency)
           if ($currency->iso_code != $defaultCurrency->iso_code)
//                $currency->refreshCurrency($feed->list, $isoCodeSource, $defaultCurrency);
               $currency->refreshCurrency($feed, $isoCodeSource, $defaultCurrency);
   }



The code is the same. The difference is that in one file is at line 188 and the PS 1.4 is in line 255.

Attached is the file for Prestashop 1.3.6.0 that you can download and put in /classes folder (rename your other file to currency.old if you want).

A hug for everyone!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...