Пример #1
0
 protected function getDatas($offset, $nb_results)
 {
     $logs = EbayApiLog::get($offset, $nb_results);
     foreach ($logs as &$log) {
         $log['data_sent'] = nl2br(TotFormat::prettyPrint($log['data_sent']));
         $log['response'] = nl2br(TotFormat::prettyPrint($log['response']));
     }
     return $logs;
 }
Пример #2
0
 public function __construct($id = null, $id_lang = null, $id_shop = null)
 {
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         self::$definition = array('table' => 'ebay_api_log', 'primary' => 'id_ebay_log', 'fields' => array('id_ebay_profile' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'type' => array('type' => self::TYPE_STRING, 'validate' => 'isString'), 'context' => array('type' => self::TYPE_STRING, 'validate' => 'isString'), 'data_sent' => array('type' => self::TYPE_STRING, 'validate' => 'isString'), 'response' => array('type' => self::TYPE_STRING, 'validate' => 'isString'), 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')));
     } else {
         $tables = array('ebay_api_log');
         $fieldsRequired = array('date_add', 'type', 'context', 'data_sent', 'reponse');
         $fieldsValidate = array();
     }
     $this->date_add = date('Y-m-d H:i:s');
     return parent::__construct($id, $id_lang, $id_shop);
 }
Пример #3
0
 function getContent()
 {
     // Load prestashop ebay's configuration
     $configs = Configuration::getMultiple(array('EBAY_SECURITY_TOKEN'));
     return $this->display('api_logs.tpl', array('nb_logs' => EbayApiLog::count(), 'configs' => $configs, 'api_not_configured' => !Configuration::get('EBAY_API_LOGS')));
 }
Пример #4
0
 private function _cleanLogs()
 {
     $config = Configuration::getMultiple(array('EBAY_LOGS_LAST_CLEANUP', 'EBAY_LOGS_DAYS', 'EBAY_API_LOGS', 'EBAY_ACTIVATE_LOGS'));
     if (isset($config['EBAY_LOGS_LAST_CLEANUP']) && $config['EBAY_LOGS_LAST_CLEANUP'] >= date('Y-m-d\\TH:i:s', strtotime('-1 day')) . '.000Z') {
         return;
     }
     $has_cleaned_logs = false;
     if (isset($config['EBAY_API_LOGS']) && $config['EBAY_API_LOGS']) {
         EbayApiLog::cleanOlderThan($config['EBAY_LOGS_DAYS']);
         $has_cleaned_logs = true;
     }
     if (isset($config['EBAY_ACTIVATE_LOGS']) && $config['EBAY_ACTIVATE_LOGS']) {
         EbayOrderLog::cleanOlderThan($config['EBAY_LOGS_DAYS']);
         $has_cleaned_logs = true;
     }
     if ($has_cleaned_logs) {
         Configuration::updateValue('EBAY_LOGS_LAST_CLEANUP', true, false, 0, 0);
     }
 }
Пример #5
0
 private function _logApiCall($type, $data_sent, $response, $id_product = null, $id_order = null)
 {
     if (!$this->write_api_logs) {
         return;
     }
     $log = new EbayApiLog();
     $log->id_ebay_profile = $this->ebay_profile->id;
     $log->type = $type;
     $log->context = $this->context;
     $log->data_sent = Tools::jsonEncode($data_sent);
     $log->response = Tools::jsonEncode($response);
     if ($id_product) {
         $log->id_product = (int) $id_product;
     }
     if ($id_order) {
         $log->id_order = (int) $id_order;
     }
     return $log->save();
 }