getContext()->getI18N(); if (!$config->get('enable')) { $this->setFlash('warning', $i18n->__('Aby korzystać z Allegro musisz je wpierw włączyć w konfiguracji')); return $this->redirect('@stAllegroPlugin?action=config'); } if ($config->get('access_token')) { try { $api = stAllegroApi::getInstance(); $api->getBasicInfoAboutUser(); } catch(stAllegroException $e) { $message = stAllegroApi::getLastErrorsAsString('
'); if ($message == 'Unauthorized') { $message = $i18n->__('Błędna autoryzacja, sprawdź poprawność wprowadzonych danych dostępowych do API', null, 'stAllegroBackend'); } if (strpos($message, 'Invalid refresh token') !== false || strpos($message, 'Access token expired') !== false) { $message = $i18n->__('Token dostępu nie może zostać odświeżony automatycznie proszę ponownie zalogować się do Allegro', null, 'stAllegroBackend'); } $this->setFlash('error', $message, true); return $this->redirect('@stAllegroPlugin?action=config'); } } elseif (!$config->get('access_token')) { $this->setFlash('error', $i18n->__('Błędna autoryzacja, sprawdź poprawność wprowadzonych danych dostępowych do API', null, 'stAllegroBackend')); return $this->redirect('@stAllegroPlugin?action=config'); } } protected function saveAllegroApiShippingRate($allegro_api_shipping_rate) { try { parent::saveAllegroApiShippingRate($allegro_api_shipping_rate); } catch (Exception $e) { foreach (stAllegroApi::getLastErrors() as $error) { if ($error->path == "name") { $this->getRequest()->setError('allegro_api_shipping_rate{name}', $error->userMessage); } elseif ($error->path) { $error->path = str_replace("items[", "rates[", $error->path); $this->getRequest()->setError($error->path, $error->userMessage); } else { $this->getRequest()->setError('{allegro_api}', $error->userMessage . ' ('. $error->message .')'); } } // echo "
".var_export(stAllegroApi::getLastErrors(), true)."
"; } } protected function getLabels() { $labels = parent::getLabels(); $labels['{allegro_api}'] = 'Allegro API'; $labels['rates'] = 'Cennik'; return $labels; } }