fix: init exception for some opencart versions
This commit is contained in:
@@ -74,11 +74,20 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
|
||||
private array $error = [];
|
||||
|
||||
public function index(): void
|
||||
public function __construct($registry)
|
||||
{
|
||||
parent::__construct($registry);
|
||||
|
||||
$this->load->language('extension/module/tgshop');
|
||||
$this->load->model('setting/setting');
|
||||
$this->load->model('tool/image');
|
||||
$this->load->model('catalog/product');
|
||||
$this->load->model('localisation/order_status');
|
||||
$this->load->model('customer/customer_group');
|
||||
}
|
||||
|
||||
public function index(): void
|
||||
{
|
||||
$hasConfig = $this->config->get('module_tgshop_app_name') !== null;
|
||||
|
||||
if ($hasConfig) {
|
||||
@@ -121,7 +130,7 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
foreach ($data['settings'] as $configs) {
|
||||
foreach ($configs as $key => $config) {
|
||||
if ($config['type'] === 'image') {
|
||||
$this->load->model('tool/image');
|
||||
|
||||
if (isset($this->request->post[$key]) && is_file(DIR_IMAGE . $this->request->post[$key])) {
|
||||
$data[$key] = $this->model_tool_image->resize($this->request->post[$key], 100, 100);
|
||||
} elseif ($this->config->get($key) && is_file(DIR_IMAGE . $this->config->get($key))) {
|
||||
@@ -131,7 +140,7 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
}
|
||||
} elseif ($config['type'] === 'products') {
|
||||
$products = $this->request->post[$key] ?? $this->config->get($key) ?? [];
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$data[$key] = [];
|
||||
foreach ($products as $productId) {
|
||||
$productItem = $this->model_catalog_product->getProduct($productId);
|
||||
@@ -275,8 +284,6 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
|
||||
private function getDefaultConfig(): array
|
||||
{
|
||||
$this->load->model('tool/image');
|
||||
|
||||
return [
|
||||
'module_tgshop_status' => 1,
|
||||
'module_tgshop_app_name' => $this->config->get('config_meta_title'),
|
||||
@@ -451,7 +458,6 @@ HTML,
|
||||
|
||||
private function getCustomerGroups(): array
|
||||
{
|
||||
$this->load->model('customer/customer_group');
|
||||
$map = [];
|
||||
|
||||
foreach ($this->model_customer_customer_group->getCustomerGroups() as $customer_group) {
|
||||
@@ -463,7 +469,6 @@ HTML,
|
||||
|
||||
private function getOrderStatuses()
|
||||
{
|
||||
$this->load->model('localisation/order_status');
|
||||
$statuses = $this->model_localisation_order_status->getOrderStatuses();
|
||||
$map = [];
|
||||
|
||||
|
||||
@@ -23,11 +23,18 @@ if (is_readable($sysLibPath . '/oc_telegram_shop.phar')) {
|
||||
/**
|
||||
* @property Config $config
|
||||
*/
|
||||
class Controllerextensiontgshophandle extends Controller
|
||||
class ControllerExtensionTgshopHandle extends Controller
|
||||
{
|
||||
public function __construct($registry)
|
||||
{
|
||||
parent::__construct($registry);
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
$this->load->model('checkout/order');
|
||||
}
|
||||
|
||||
public function index(): void
|
||||
{
|
||||
$this->load->model('checkout/order');
|
||||
$this->session->data['language'] = $this->config->get('config_language');
|
||||
|
||||
$app = ApplicationFactory::create([
|
||||
@@ -75,7 +82,7 @@ class Controllerextensiontgshophandle extends Controller
|
||||
]);
|
||||
|
||||
$app->bind(OcModelCatalogProductAdapter::class, function () {
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
return new OcModelCatalogProductAdapter($this->model_catalog_product);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user