diff --git a/admin/controller/module/easy_import_nat.php b/admin/controller/module/easy_import_nat.php index 334d11d..c19f53d 100644 --- a/admin/controller/module/easy_import_nat.php +++ b/admin/controller/module/easy_import_nat.php @@ -614,9 +614,9 @@ class EasyImportNat extends \Opencart\System\Engine\Controller { } $zip_file = DIR_CACHE . 'backup_prices_stock_' . date('Y-m-d_H-i-s') . '_' . uniqid() . '.zip'; - $zip = new ZipArchive(); + $zip = new \ZipArchive(); - if ($zip->open($zip_file, ZipArchive::CREATE) !== TRUE) { + if ($zip->open($zip_file, \ZipArchive::CREATE) !== TRUE) { die('Cannot create zip file on server'); } @@ -2426,8 +2426,8 @@ public function deleteCronProfile() { private function extractCompressedFile($src_file, $original_filename, &$ext) { $temp_extracted = DIR_CACHE . 'nat_extract_' . md5(uniqid('nat_', true)); if ($ext === 'zip') { - if (class_exists('ZipArchive')) { - $zip = new ZipArchive; + if (class_exists('\\ZipArchive')) { + $zip = new \ZipArchive; if ($zip->open($src_file) === TRUE) { $found_file = ''; $found_ext = ''; @@ -3975,7 +3975,7 @@ private function formatPriceImport($price) { } // Pagination - $pagination = new Pagination(); + $pagination = new \Opencart\System\Library\Pagination(); $pagination->total = $total; $pagination->page = $page; $pagination->limit = $limit; @@ -4005,7 +4005,7 @@ private function formatPriceImport($price) { public function downloadLogFile() { if (!isset($this->request->get['user_token']) || !isset($this->session->data['user_token']) || $this->request->get['user_token'] !== $this->session->data['user_token'] || !$this->user->hasPermission('access', 'extension/easy_import_nat/module/easy_import_nat')) { - return new Action('error/not_found'); + return new \Opencart\System\Engine\Action('error/not_found'); } if (isset($this->request->get['file'])) { $file = basename($this->request->get['file']); diff --git a/admin/model/module/easy_import_nat.php b/admin/model/module/easy_import_nat.php index 333881a..75f0532 100644 --- a/admin/model/module/easy_import_nat.php +++ b/admin/model/module/easy_import_nat.php @@ -550,7 +550,7 @@ class EasyImportNat extends \Opencart\System\Engine\Model { try { $this->db->query("ALTER TABLE `" . $table_name . "` ADD `" . $column_name . "` VARCHAR(255) NOT NULL DEFAULT ''"); self::$schema_cache[$table_name . '.' . $column_name] = true; - } catch (Exception $e) { + } catch (\Throwable $e) { return false; } } @@ -603,7 +603,7 @@ class EasyImportNat extends \Opencart\System\Engine\Model { } else { $this->db->query("INSERT INTO `" . $table_name . "` SET product_id = '" . (int)$product_id . "', `" . $column_name . "` = '" . $this->db->escape($value) . "'"); } - } catch (Exception $e) { + } catch (\Throwable $e) { return false; } } diff --git a/catalog/controller/module/easy_import_nat_cron.php b/catalog/controller/module/easy_import_nat_cron.php index 708dfb7..12f3a81 100644 --- a/catalog/controller/module/easy_import_nat_cron.php +++ b/catalog/controller/module/easy_import_nat_cron.php @@ -67,15 +67,29 @@ class EasyImportNatCron extends \Opencart\System\Engine\Controller { } }); - $admin_model_path = DIR_APPLICATION . '../admin/model/extension/module/easy_import_nat.php'; - if (!file_exists($admin_model_path)) { + $$admin_model_path = ''; + if (defined('DIR_EXTENSION') && is_file(DIR_EXTENSION . 'easy_import_nat/admin/model/module/easy_import_nat.php')) { + $admin_model_path = DIR_EXTENSION . 'easy_import_nat/admin/model/module/easy_import_nat.php'; + } elseif (is_file(DIR_APPLICATION . '../extension/easy_import_nat/admin/model/module/easy_import_nat.php')) { + $admin_model_path = DIR_APPLICATION . '../extension/easy_import_nat/admin/model/module/easy_import_nat.php'; + } elseif (is_file(DIR_APPLICATION . '../admin/model/extension/module/easy_import_nat.php')) { + $admin_model_path = DIR_APPLICATION . '../admin/model/extension/module/easy_import_nat.php'; + } + + if (!$admin_model_path || !file_exists($admin_model_path)) { if ($lock_fp) { flock($lock_fp, LOCK_UN); fclose($lock_fp); } if ($lock_file && file_exists($lock_file)) { @unlink($lock_file); } exit("Admin model file not found\n"); } - + require_once $admin_model_path; - $model = new ModelExtensionModuleEasyImportNat($this->registry); + if (class_exists('\\Opencart\\Admin\\Model\\Extension\\EasyImportNat\\Module\\EasyImportNat')) { + $model = new \Opencart\Admin\Model\Extension\EasyImportNat\Module\EasyImportNat($this->registry); + } elseif (class_exists('ModelExtensionModuleEasyImportNat')) { + $model = new \ModelExtensionModuleEasyImportNat($this->registry); + } else { + exit("Admin model class not found\n"); + } $profile = $model->getCronProfile($profile_id); if (!$profile || empty($profile['status'])) { @@ -2463,8 +2477,8 @@ class EasyImportNatCron extends \Opencart\System\Engine\Controller { private function extractCompressedFile($src_file, $original_filename, &$ext) { $temp_extracted = DIR_CACHE . 'nat_extract_' . md5(uniqid('nat_', true)); if ($ext === 'zip') { - if (class_exists('ZipArchive')) { - $zip = new ZipArchive; + if (class_exists('\\ZipArchive')) { + $zip = new \ZipArchive; if ($zip->open($src_file) === TRUE) { $found_file = ''; $found_ext = ''; diff --git a/easy_import_export_nat_OC_41_1_0.ocmod.zip b/easy_import_export_nat_OC_41_1_0.ocmod.zip index 19199ea..9fea7c8 100644 Binary files a/easy_import_export_nat_OC_41_1_0.ocmod.zip and b/easy_import_export_nat_OC_41_1_0.ocmod.zip differ diff --git a/easy_import_nat.ocmod.zip b/easy_import_nat.ocmod.zip index 19199ea..9fea7c8 100644 Binary files a/easy_import_nat.ocmod.zip and b/easy_import_nat.ocmod.zip differ