| 1: | <?php
|
| 2: | namespace Opencart\Admin\Controller\Setting;
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class Store extends \Opencart\System\Engine\Controller {
|
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: |
|
| 14: | public function index(): void {
|
| 15: | $this->load->language('setting/store');
|
| 16: |
|
| 17: | $this->document->setTitle($this->language->get('heading_title'));
|
| 18: |
|
| 19: | $url = '';
|
| 20: |
|
| 21: | if (isset($this->request->get['page'])) {
|
| 22: | $url .= '&page=' . $this->request->get['page'];
|
| 23: | }
|
| 24: |
|
| 25: | $data['breadcrumbs'] = [];
|
| 26: |
|
| 27: | $data['breadcrumbs'][] = [
|
| 28: | 'text' => $this->language->get('text_home'),
|
| 29: | 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
| 30: | ];
|
| 31: |
|
| 32: | $data['breadcrumbs'][] = [
|
| 33: | 'text' => $this->language->get('heading_title'),
|
| 34: | 'href' => $this->url->link('setting/store', 'user_token=' . $this->session->data['user_token'] . $url)
|
| 35: | ];
|
| 36: |
|
| 37: | $data['add'] = $this->url->link('setting/store.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
| 38: | $data['delete'] = $this->url->link('setting/store.delete', 'user_token=' . $this->session->data['user_token']);
|
| 39: |
|
| 40: | $data['list'] = $this->getList();
|
| 41: |
|
| 42: | $data['user_token'] = $this->session->data['user_token'];
|
| 43: |
|
| 44: | $data['header'] = $this->load->controller('common/header');
|
| 45: | $data['column_left'] = $this->load->controller('common/column_left');
|
| 46: | $data['footer'] = $this->load->controller('common/footer');
|
| 47: |
|
| 48: | $this->response->setOutput($this->load->view('setting/store', $data));
|
| 49: | }
|
| 50: |
|
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: |
|
| 56: | public function list(): void {
|
| 57: | $this->load->language('setting/store');
|
| 58: |
|
| 59: | $this->response->setOutput($this->getList());
|
| 60: | }
|
| 61: |
|
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: |
|
| 67: | protected function getList(): string {
|
| 68: | if (isset($this->request->get['page'])) {
|
| 69: | $page = (int)$this->request->get['page'];
|
| 70: | } else {
|
| 71: | $page = 1;
|
| 72: | }
|
| 73: |
|
| 74: | $url = '';
|
| 75: |
|
| 76: | if (isset($this->request->get['page'])) {
|
| 77: | $url .= '&page=' . $this->request->get['page'];
|
| 78: | }
|
| 79: |
|
| 80: | $data['action'] = $this->url->link('setting/store.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
| 81: |
|
| 82: | $data['stores'] = [];
|
| 83: |
|
| 84: | $store_total = 0;
|
| 85: |
|
| 86: | if ($page == 1) {
|
| 87: | $store_total = 1;
|
| 88: |
|
| 89: | $data['stores'][] = [
|
| 90: | 'store_id' => 0,
|
| 91: | 'name' => $this->config->get('config_name') . $this->language->get('text_default'),
|
| 92: | 'url' => HTTP_CATALOG,
|
| 93: | 'edit' => $this->url->link('setting/setting', 'user_token=' . $this->session->data['user_token'])
|
| 94: | ];
|
| 95: | }
|
| 96: |
|
| 97: | $this->load->model('setting/store');
|
| 98: |
|
| 99: | $results = $this->model_setting_store->getStores();
|
| 100: |
|
| 101: | foreach ($results as $result) {
|
| 102: | $data['stores'][] = [
|
| 103: | 'store_id' => $result['store_id'],
|
| 104: | 'name' => $result['name'],
|
| 105: | 'url' => $result['url'],
|
| 106: | 'edit' => $this->url->link('setting/store.form', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $result['store_id'])
|
| 107: | ];
|
| 108: | }
|
| 109: |
|
| 110: | $store_total += $this->model_setting_store->getTotalStores();
|
| 111: |
|
| 112: | $data['pagination'] = $this->load->controller('common/pagination', [
|
| 113: | 'total' => $store_total,
|
| 114: | 'page' => $page,
|
| 115: | 'limit' => $this->config->get('config_pagination_admin'),
|
| 116: | 'url' => $this->url->link('setting/store.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
| 117: | ]);
|
| 118: |
|
| 119: | $data['results'] = sprintf($this->language->get('text_pagination'), ($store_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($store_total - $this->config->get('config_pagination_admin'))) ? $store_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $store_total, ceil($store_total / $this->config->get('config_pagination_admin')));
|
| 120: |
|
| 121: | return $this->load->view('setting/store_list', $data);
|
| 122: | }
|
| 123: |
|
| 124: | |
| 125: | |
| 126: | |
| 127: | |
| 128: |
|
| 129: | public function form(): void {
|
| 130: | $this->load->language('setting/store');
|
| 131: |
|
| 132: | $this->document->setTitle($this->language->get('heading_title'));
|
| 133: |
|
| 134: | $data['text_form'] = !isset($this->request->get['store_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
| 135: |
|
| 136: | $url = '';
|
| 137: |
|
| 138: | if (isset($this->request->get['page'])) {
|
| 139: | $url .= '&page=' . $this->request->get['page'];
|
| 140: | }
|
| 141: |
|
| 142: | $data['breadcrumbs'] = [];
|
| 143: |
|
| 144: | $data['breadcrumbs'][] = [
|
| 145: | 'text' => $this->language->get('text_home'),
|
| 146: | 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
| 147: | ];
|
| 148: |
|
| 149: | $data['breadcrumbs'][] = [
|
| 150: | 'text' => $this->language->get('heading_title'),
|
| 151: | 'href' => $this->url->link('setting/store', 'user_token=' . $this->session->data['user_token'])
|
| 152: | ];
|
| 153: |
|
| 154: | $data['breadcrumbs'][] = [
|
| 155: | 'text' => $this->language->get('text_settings'),
|
| 156: | 'href' => $this->url->link('setting/store.form', 'user_token=' . $this->session->data['user_token'] . (isset($this->request->post['store_id']) ? '&store_id=' . $this->request->get['store_id'] : '') . $url)
|
| 157: | ];
|
| 158: |
|
| 159: | $data['save'] = $this->url->link('setting/store.save', 'user_token=' . $this->session->data['user_token']);
|
| 160: | $data['back'] = $this->url->link('setting/store', 'user_token=' . $this->session->data['user_token']);
|
| 161: |
|
| 162: | if (isset($this->request->get['store_id'])) {
|
| 163: | $this->load->model('setting/setting');
|
| 164: |
|
| 165: | $store_info = $this->model_setting_setting->getSetting('config', $this->request->get['store_id']);
|
| 166: | }
|
| 167: |
|
| 168: | if (isset($this->request->get['store_id'])) {
|
| 169: | $data['store_id'] = (int)$this->request->get['store_id'];
|
| 170: | } else {
|
| 171: | $data['store_id'] = 0;
|
| 172: | }
|
| 173: |
|
| 174: | if (isset($store_info['config_url'])) {
|
| 175: | $data['config_url'] = $store_info['config_url'];
|
| 176: | } else {
|
| 177: | $data['config_url'] = '';
|
| 178: | }
|
| 179: |
|
| 180: | if (isset($store_info['config_meta_title'])) {
|
| 181: | $data['config_meta_title'] = $store_info['config_meta_title'];
|
| 182: | } else {
|
| 183: | $data['config_meta_title'] = '';
|
| 184: | }
|
| 185: |
|
| 186: | if (isset($store_info['config_meta_description'])) {
|
| 187: | $data['config_meta_description'] = $store_info['config_meta_description'];
|
| 188: | } else {
|
| 189: | $data['config_meta_description'] = '';
|
| 190: | }
|
| 191: |
|
| 192: | if (isset($store_info['config_meta_keyword'])) {
|
| 193: | $data['config_meta_keyword'] = $store_info['config_meta_keyword'];
|
| 194: | } else {
|
| 195: | $data['config_meta_keyword'] = '';
|
| 196: | }
|
| 197: |
|
| 198: | $data['themes'] = [];
|
| 199: |
|
| 200: | $this->load->model('setting/extension');
|
| 201: |
|
| 202: | $extensions = $this->model_setting_extension->getExtensionsByType('theme');
|
| 203: |
|
| 204: | foreach ($extensions as $extension) {
|
| 205: | $this->load->language('extension/' . $extension['extension'] . '/theme/' . $extension['code'], 'extension');
|
| 206: |
|
| 207: | $data['themes'][] = [
|
| 208: | 'text' => $this->language->get('extension_heading_title'),
|
| 209: | 'value' => $extension['code']
|
| 210: | ];
|
| 211: | }
|
| 212: |
|
| 213: | if (isset($store_info['config_theme'])) {
|
| 214: | $data['config_theme'] = $store_info['config_theme'];
|
| 215: | } else {
|
| 216: | $data['config_theme'] = '';
|
| 217: | }
|
| 218: |
|
| 219: | $this->load->model('design/layout');
|
| 220: |
|
| 221: | $data['layouts'] = $this->model_design_layout->getLayouts();
|
| 222: |
|
| 223: | if (isset($store_info['config_layout_id'])) {
|
| 224: | $data['config_layout_id'] = $store_info['config_layout_id'];
|
| 225: | } else {
|
| 226: | $data['config_layout_id'] = '';
|
| 227: | }
|
| 228: |
|
| 229: | if (isset($store_info['config_name'])) {
|
| 230: | $data['config_name'] = $store_info['config_name'];
|
| 231: | } else {
|
| 232: | $data['config_name'] = '';
|
| 233: | }
|
| 234: |
|
| 235: | if (isset($store_info['config_owner'])) {
|
| 236: | $data['config_owner'] = $store_info['config_owner'];
|
| 237: | } else {
|
| 238: | $data['config_owner'] = '';
|
| 239: | }
|
| 240: |
|
| 241: | if (isset($store_info['config_address'])) {
|
| 242: | $data['config_address'] = $store_info['config_address'];
|
| 243: | } else {
|
| 244: | $data['config_address'] = '';
|
| 245: | }
|
| 246: |
|
| 247: | if (isset($store_info['config_geocode'])) {
|
| 248: | $data['config_geocode'] = $store_info['config_geocode'];
|
| 249: | } else {
|
| 250: | $data['config_geocode'] = '';
|
| 251: | }
|
| 252: |
|
| 253: | if (isset($store_info['config_email'])) {
|
| 254: | $data['config_email'] = $store_info['config_email'];
|
| 255: | } else {
|
| 256: | $data['config_email'] = '';
|
| 257: | }
|
| 258: |
|
| 259: | if (isset($store_info['config_telephone'])) {
|
| 260: | $data['config_telephone'] = $store_info['config_telephone'];
|
| 261: | } else {
|
| 262: | $data['config_telephone'] = '';
|
| 263: | }
|
| 264: |
|
| 265: | if (isset($store_info['config_image'])) {
|
| 266: | $data['config_image'] = $store_info['config_image'];
|
| 267: | } else {
|
| 268: | $data['config_image'] = '';
|
| 269: | }
|
| 270: |
|
| 271: | $this->load->model('tool/image');
|
| 272: |
|
| 273: | $data['placeholder'] = $this->model_tool_image->resize('no_image.png', $this->config->get('config_image_default_width'), $this->config->get('config_image_default_height'));
|
| 274: |
|
| 275: | if ($data['config_image'] && is_file(DIR_IMAGE . html_entity_decode($data['config_image'], ENT_QUOTES, 'UTF-8'))) {
|
| 276: | $data['thumb'] = $this->model_tool_image->resize($data['config_image'], $this->config->get('config_image_default_width'), $this->config->get('config_image_default_height'));
|
| 277: | } else {
|
| 278: | $data['thumb'] = $data['placeholder'];
|
| 279: | }
|
| 280: |
|
| 281: | if (isset($store_info['config_open'])) {
|
| 282: | $data['config_open'] = $store_info['config_open'];
|
| 283: | } else {
|
| 284: | $data['config_open'] = '';
|
| 285: | }
|
| 286: |
|
| 287: | if (isset($store_info['config_comment'])) {
|
| 288: | $data['config_comment'] = $store_info['config_comment'];
|
| 289: | } else {
|
| 290: | $data['config_comment'] = '';
|
| 291: | }
|
| 292: |
|
| 293: | $this->load->model('localisation/location');
|
| 294: |
|
| 295: | $data['locations'] = $this->model_localisation_location->getLocations();
|
| 296: |
|
| 297: | if (isset($store_info['config_location'])) {
|
| 298: | $data['config_location'] = $store_info['config_location'];
|
| 299: | } else {
|
| 300: | $data['config_location'] = [];
|
| 301: | }
|
| 302: |
|
| 303: | $this->load->model('localisation/country');
|
| 304: |
|
| 305: | $data['countries'] = $this->model_localisation_country->getCountries();
|
| 306: |
|
| 307: | if (isset($store_info['config_country_id'])) {
|
| 308: | $data['config_country_id'] = $store_info['config_country_id'];
|
| 309: | } else {
|
| 310: | $data['config_country_id'] = $this->config->get('config_country_id');
|
| 311: | }
|
| 312: |
|
| 313: | if (isset($store_info['config_zone_id'])) {
|
| 314: | $data['config_zone_id'] = $store_info['config_zone_id'];
|
| 315: | } else {
|
| 316: | $data['config_zone_id'] = $this->config->get('config_zone_id');
|
| 317: | }
|
| 318: |
|
| 319: | $this->load->model('localisation/language');
|
| 320: |
|
| 321: | $data['languages'] = $this->model_localisation_language->getLanguages();
|
| 322: |
|
| 323: | if (isset($store_info['config_language_catalog'])) {
|
| 324: | $data['config_language_catalog'] = $store_info['config_language_catalog'];
|
| 325: | } else {
|
| 326: | $data['config_language_catalog'] = $this->config->get('config_language_catalog');
|
| 327: | }
|
| 328: |
|
| 329: | $this->load->model('localisation/currency');
|
| 330: |
|
| 331: | $data['currencies'] = $this->model_localisation_currency->getCurrencies();
|
| 332: |
|
| 333: | if (isset($store_info['config_currency'])) {
|
| 334: | $data['config_currency'] = $store_info['config_currency'];
|
| 335: | } else {
|
| 336: | $data['config_currency'] = $this->config->get('config_currency');
|
| 337: | }
|
| 338: |
|
| 339: |
|
| 340: | if (isset($store_info['config_product_description_length'])) {
|
| 341: | $data['config_product_description_length'] = $store_info['config_product_description_length'];
|
| 342: | } else {
|
| 343: | $data['config_product_description_length'] = 100;
|
| 344: | }
|
| 345: |
|
| 346: | if (isset($store_info['config_pagination'])) {
|
| 347: | $data['config_pagination'] = $store_info['config_pagination'];
|
| 348: | } else {
|
| 349: | $data['config_pagination'] = 15;
|
| 350: | }
|
| 351: |
|
| 352: | if (isset($store_info['config_product_count'])) {
|
| 353: | $data['config_product_count'] = $store_info['config_product_count'];
|
| 354: | } else {
|
| 355: | $data['config_product_count'] = 10;
|
| 356: | }
|
| 357: |
|
| 358: | if (isset($store_info['config_cookie_id'])) {
|
| 359: | $data['config_cookie_id'] = $store_info['config_cookie_id'];
|
| 360: | } else {
|
| 361: | $data['config_cookie_id'] = '';
|
| 362: | }
|
| 363: |
|
| 364: | if (isset($store_info['config_gdpr_id'])) {
|
| 365: | $data['config_gdpr_id'] = $store_info['config_gdpr_id'];
|
| 366: | } else {
|
| 367: | $data['config_gdpr_id'] = '';
|
| 368: | }
|
| 369: |
|
| 370: | if (isset($store_info['config_tax'])) {
|
| 371: | $data['config_tax'] = $store_info['config_tax'];
|
| 372: | } else {
|
| 373: | $data['config_tax'] = '';
|
| 374: | }
|
| 375: |
|
| 376: | if (isset($store_info['config_tax_default'])) {
|
| 377: | $data['config_tax_default'] = $store_info['config_tax_default'];
|
| 378: | } else {
|
| 379: | $data['config_tax_default'] = '';
|
| 380: | }
|
| 381: |
|
| 382: | if (isset($store_info['config_tax_customer'])) {
|
| 383: | $data['config_tax_customer'] = $store_info['config_tax_customer'];
|
| 384: | } else {
|
| 385: | $data['config_tax_customer'] = '';
|
| 386: | }
|
| 387: |
|
| 388: | $this->load->model('customer/customer_group');
|
| 389: |
|
| 390: | $data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups();
|
| 391: |
|
| 392: | if (isset($store_info['config_customer_group_id'])) {
|
| 393: | $data['config_customer_group_id'] = $store_info['config_customer_group_id'];
|
| 394: | } else {
|
| 395: | $data['config_customer_group_id'] = '';
|
| 396: | }
|
| 397: |
|
| 398: | if (isset($store_info['config_customer_group_display'])) {
|
| 399: | $data['config_customer_group_display'] = $store_info['config_customer_group_display'];
|
| 400: | } else {
|
| 401: | $data['config_customer_group_display'] = [];
|
| 402: | }
|
| 403: |
|
| 404: | if (isset($store_info['config_customer_price'])) {
|
| 405: | $data['config_customer_price'] = $store_info['config_customer_price'];
|
| 406: | } else {
|
| 407: | $data['config_customer_price'] = '';
|
| 408: | }
|
| 409: |
|
| 410: | $this->load->model('catalog/information');
|
| 411: |
|
| 412: | $data['informations'] = $this->model_catalog_information->getInformations();
|
| 413: |
|
| 414: | if (isset($store_info['config_account_id'])) {
|
| 415: | $data['config_account_id'] = $store_info['config_account_id'];
|
| 416: | } else {
|
| 417: | $data['config_account_id'] = '';
|
| 418: | }
|
| 419: |
|
| 420: | if (isset($store_info['config_cart_weight'])) {
|
| 421: | $data['config_cart_weight'] = $store_info['config_cart_weight'];
|
| 422: | } else {
|
| 423: | $data['config_cart_weight'] = '';
|
| 424: | }
|
| 425: |
|
| 426: | if (isset($store_info['config_checkout_guest'])) {
|
| 427: | $data['config_checkout_guest'] = $store_info['config_checkout_guest'];
|
| 428: | } else {
|
| 429: | $data['config_checkout_guest'] = '';
|
| 430: | }
|
| 431: |
|
| 432: | if (isset($store_info['config_checkout_id'])) {
|
| 433: | $data['config_checkout_id'] = $store_info['config_checkout_id'];
|
| 434: | } else {
|
| 435: | $data['config_checkout_id'] = '';
|
| 436: | }
|
| 437: |
|
| 438: | if (isset($store_info['config_stock_display'])) {
|
| 439: | $data['config_stock_display'] = $store_info['config_stock_display'];
|
| 440: | } else {
|
| 441: | $data['config_stock_display'] = '';
|
| 442: | }
|
| 443: |
|
| 444: | if (isset($store_info['config_stock_checkout'])) {
|
| 445: | $data['config_stock_checkout'] = $store_info['config_stock_checkout'];
|
| 446: | } else {
|
| 447: | $data['config_stock_checkout'] = '';
|
| 448: | }
|
| 449: |
|
| 450: |
|
| 451: | if (isset($store_info['config_logo'])) {
|
| 452: | $data['config_logo'] = $store_info['config_logo'];
|
| 453: | } else {
|
| 454: | $data['config_logo'] = '';
|
| 455: | }
|
| 456: |
|
| 457: | $this->load->model('tool/image');
|
| 458: |
|
| 459: | $data['placeholder'] = $this->model_tool_image->resize('no_image.png', $this->config->get('config_image_default_width'), $this->config->get('config_image_default_height'));
|
| 460: |
|
| 461: | if ($data['config_logo'] && is_file(DIR_IMAGE . html_entity_decode($data['config_logo'], ENT_QUOTES, 'UTF-8'))) {
|
| 462: | $data['logo'] = $this->model_tool_image->resize($data['config_logo'], $this->config->get('config_image_default_width'), $this->config->get('config_image_default_height'));
|
| 463: | } else {
|
| 464: | $data['logo'] = $data['placeholder'];
|
| 465: | }
|
| 466: |
|
| 467: | if (isset($store_info['config_image_category_width'])) {
|
| 468: | $data['config_image_category_width'] = $store_info['config_image_category_width'];
|
| 469: | } else {
|
| 470: | $data['config_image_category_width'] = 80;
|
| 471: | }
|
| 472: |
|
| 473: | if (isset($store_info['config_image_category_height'])) {
|
| 474: | $data['config_image_category_height'] = $store_info['config_image_category_height'];
|
| 475: | } else {
|
| 476: | $data['config_image_category_height'] = 80;
|
| 477: | }
|
| 478: |
|
| 479: | if (isset($store_info['config_image_thumb_width'])) {
|
| 480: | $data['config_image_thumb_width'] = $store_info['config_image_thumb_width'];
|
| 481: | } else {
|
| 482: | $data['config_image_thumb_width'] = 228;
|
| 483: | }
|
| 484: |
|
| 485: | if (isset($store_info['config_image_thumb_height'])) {
|
| 486: | $data['config_image_thumb_height'] = $store_info['config_image_thumb_height'];
|
| 487: | } else {
|
| 488: | $data['config_image_thumb_height'] = 228;
|
| 489: | }
|
| 490: |
|
| 491: | if (isset($store_info['config_image_popup_width'])) {
|
| 492: | $data['config_image_popup_width'] = $store_info['config_image_popup_width'];
|
| 493: | } else {
|
| 494: | $data['config_image_popup_width'] = 500;
|
| 495: | }
|
| 496: |
|
| 497: | if (isset($store_info['config_image_popup_height'])) {
|
| 498: | $data['config_image_popup_height'] = $store_info['config_image_popup_height'];
|
| 499: | } else {
|
| 500: | $data['config_image_popup_height'] = 500;
|
| 501: | }
|
| 502: |
|
| 503: | if (isset($store_info['config_image_product_width'])) {
|
| 504: | $data['config_image_product_width'] = $store_info['config_image_product_width'];
|
| 505: | } else {
|
| 506: | $data['config_image_product_width'] = 228;
|
| 507: | }
|
| 508: |
|
| 509: | if (isset($store_info['config_image_product_height'])) {
|
| 510: | $data['config_image_product_height'] = $store_info['config_image_product_height'];
|
| 511: | } else {
|
| 512: | $data['config_image_product_height'] = 228;
|
| 513: | }
|
| 514: |
|
| 515: | if (isset($store_info['config_image_additional_width'])) {
|
| 516: | $data['config_image_additional_width'] = $store_info['config_image_additional_width'];
|
| 517: | } else {
|
| 518: | $data['config_image_additional_width'] = 74;
|
| 519: | }
|
| 520: |
|
| 521: | if (isset($store_info['config_image_additional_height'])) {
|
| 522: | $data['config_image_additional_height'] = $store_info['config_image_additional_height'];
|
| 523: | } else {
|
| 524: | $data['config_image_additional_height'] = 74;
|
| 525: | }
|
| 526: |
|
| 527: | if (isset($store_info['config_image_related_width'])) {
|
| 528: | $data['config_image_related_width'] = $store_info['config_image_related_width'];
|
| 529: | } else {
|
| 530: | $data['config_image_related_width'] = 80;
|
| 531: | }
|
| 532: |
|
| 533: | if (isset($store_info['config_image_related_height'])) {
|
| 534: | $data['config_image_related_height'] = $store_info['config_image_related_height'];
|
| 535: | } else {
|
| 536: | $data['config_image_related_height'] = 74;
|
| 537: | }
|
| 538: |
|
| 539: | if (isset($store_info['config_image_article_width'])) {
|
| 540: | $data['config_image_article_width'] = $store_info['config_image_article_width'];
|
| 541: | } else {
|
| 542: | $data['config_image_article_width'] = 1140;
|
| 543: | }
|
| 544: |
|
| 545: | if (isset($store_info['config_image_article_height'])) {
|
| 546: | $data['config_image_article_height'] = $store_info['config_image_article_height'];
|
| 547: | } else {
|
| 548: | $data['config_image_article_height'] = 380;
|
| 549: | }
|
| 550: |
|
| 551: | if (isset($store_info['config_image_topic_width'])) {
|
| 552: | $data['config_image_topic_width'] = $store_info['config_image_topic_width'];
|
| 553: | } else {
|
| 554: | $data['config_image_topic_width'] = 1140;
|
| 555: | }
|
| 556: |
|
| 557: | if (isset($store_info['config_image_topic_height'])) {
|
| 558: | $data['config_image_topic_height'] = $store_info['config_image_topic_height'];
|
| 559: | } else {
|
| 560: | $data['config_image_topic_height'] = 380;
|
| 561: | }
|
| 562: |
|
| 563: | if (isset($store_info['config_image_compare_width'])) {
|
| 564: | $data['config_image_compare_width'] = $store_info['config_image_compare_width'];
|
| 565: | } else {
|
| 566: | $data['config_image_compare_width'] = 90;
|
| 567: | }
|
| 568: |
|
| 569: | if (isset($store_info['config_image_compare_height'])) {
|
| 570: | $data['config_image_compare_height'] = $store_info['config_image_compare_height'];
|
| 571: | } else {
|
| 572: | $data['config_image_compare_height'] = 90;
|
| 573: | }
|
| 574: |
|
| 575: | if (isset($store_info['config_image_wishlist_width'])) {
|
| 576: | $data['config_image_wishlist_width'] = $store_info['config_image_wishlist_width'];
|
| 577: | } else {
|
| 578: | $data['config_image_wishlist_width'] = 47;
|
| 579: | }
|
| 580: |
|
| 581: | if (isset($store_info['config_image_wishlist_height'])) {
|
| 582: | $data['config_image_wishlist_height'] = $store_info['config_image_wishlist_height'];
|
| 583: | } else {
|
| 584: | $data['config_image_wishlist_height'] = 47;
|
| 585: | }
|
| 586: |
|
| 587: | if (isset($store_info['config_image_cart_width'])) {
|
| 588: | $data['config_image_cart_width'] = $store_info['config_image_cart_width'];
|
| 589: | } else {
|
| 590: | $data['config_image_cart_width'] = 47;
|
| 591: | }
|
| 592: |
|
| 593: | if (isset($store_info['config_image_cart_height'])) {
|
| 594: | $data['config_image_cart_height'] = $store_info['config_image_cart_height'];
|
| 595: | } else {
|
| 596: | $data['config_image_cart_height'] = 47;
|
| 597: | }
|
| 598: |
|
| 599: | if (isset($store_info['config_image_location_width'])) {
|
| 600: | $data['config_image_location_width'] = $store_info['config_image_location_width'];
|
| 601: | } else {
|
| 602: | $data['config_image_location_width'] = 268;
|
| 603: | }
|
| 604: |
|
| 605: | if (isset($store_info['config_image_location_height'])) {
|
| 606: | $data['config_image_location_height'] = $store_info['config_image_location_height'];
|
| 607: | } else {
|
| 608: | $data['config_image_location_height'] = 50;
|
| 609: | }
|
| 610: |
|
| 611: | $data['user_token'] = $this->session->data['user_token'];
|
| 612: |
|
| 613: | $data['header'] = $this->load->controller('common/header');
|
| 614: | $data['column_left'] = $this->load->controller('common/column_left');
|
| 615: | $data['footer'] = $this->load->controller('common/footer');
|
| 616: |
|
| 617: | $this->response->setOutput($this->load->view('setting/store_form', $data));
|
| 618: | }
|
| 619: |
|
| 620: | |
| 621: | |
| 622: | |
| 623: | |
| 624: |
|
| 625: | public function save(): void {
|
| 626: | $this->load->language('setting/store');
|
| 627: |
|
| 628: | $json = [];
|
| 629: |
|
| 630: | if (!$this->user->hasPermission('modify', 'setting/store')) {
|
| 631: | $json['error']['warning'] = $this->language->get('error_permission');
|
| 632: | }
|
| 633: |
|
| 634: | if (!$this->request->post['config_url']) {
|
| 635: | $json['error']['url'] = $this->language->get('error_url');
|
| 636: | }
|
| 637: |
|
| 638: | if (!$this->request->post['config_meta_title']) {
|
| 639: | $json['error']['meta_title'] = $this->language->get('error_meta_title');
|
| 640: | }
|
| 641: |
|
| 642: | if (!$this->request->post['config_name']) {
|
| 643: | $json['error']['name'] = $this->language->get('error_name');
|
| 644: | }
|
| 645: |
|
| 646: | if ((oc_strlen($this->request->post['config_owner']) < 3) || (oc_strlen($this->request->post['config_owner']) > 64)) {
|
| 647: | $json['error']['owner'] = $this->language->get('error_owner');
|
| 648: | }
|
| 649: |
|
| 650: | if ((oc_strlen($this->request->post['config_address']) < 3) || (oc_strlen($this->request->post['config_address']) > 256)) {
|
| 651: | $json['error']['address'] = $this->language->get('error_address');
|
| 652: | }
|
| 653: |
|
| 654: | if ((oc_strlen($this->request->post['config_email']) > 96) || !filter_var($this->request->post['config_email'], FILTER_VALIDATE_EMAIL)) {
|
| 655: | $json['error']['email'] = $this->language->get('error_email');
|
| 656: | }
|
| 657: |
|
| 658: | if (!empty($this->request->post['config_customer_group_display']) && !in_array($this->request->post['config_customer_group_id'], $this->request->post['config_customer_group_display'])) {
|
| 659: | $json['error']['customer_group_display'] = $this->language->get('error_customer_group_display');
|
| 660: | }
|
| 661: |
|
| 662: | if (!$this->request->post['config_product_description_length']) {
|
| 663: | $json['error']['product_description_length'] = $this->language->get('error_product_description_length');
|
| 664: | }
|
| 665: |
|
| 666: | if (!$this->request->post['config_pagination']) {
|
| 667: | $json['error']['pagination'] = $this->language->get('error_pagination');
|
| 668: | }
|
| 669: |
|
| 670: | if (!$this->request->post['config_image_category_width'] || !$this->request->post['config_image_category_height']) {
|
| 671: | $json['error']['image_category'] = $this->language->get('error_image_category');
|
| 672: | }
|
| 673: |
|
| 674: | if (!$this->request->post['config_image_thumb_width'] || !$this->request->post['config_image_thumb_height']) {
|
| 675: | $json['error']['image_thumb'] = $this->language->get('error_image_thumb');
|
| 676: | }
|
| 677: |
|
| 678: | if (!$this->request->post['config_image_popup_width'] || !$this->request->post['config_image_popup_height']) {
|
| 679: | $json['error']['image_popup'] = $this->language->get('error_image_popup');
|
| 680: | }
|
| 681: |
|
| 682: | if (!$this->request->post['config_image_product_width'] || !$this->request->post['config_image_product_height']) {
|
| 683: | $json['error']['image_product'] = $this->language->get('error_image_product');
|
| 684: | }
|
| 685: |
|
| 686: | if (!$this->request->post['config_image_additional_width'] || !$this->request->post['config_image_additional_height']) {
|
| 687: | $json['error']['image_additional'] = $this->language->get('error_image_additional');
|
| 688: | }
|
| 689: |
|
| 690: | if (!$this->request->post['config_image_related_width'] || !$this->request->post['config_image_related_height']) {
|
| 691: | $json['error']['image_related'] = $this->language->get('error_image_related');
|
| 692: | }
|
| 693: |
|
| 694: | if (!$this->request->post['config_image_article_width'] || !$this->request->post['config_image_article_height']) {
|
| 695: | $json['error']['image_article'] = $this->language->get('error_image_article');
|
| 696: | }
|
| 697: |
|
| 698: | if (!$this->request->post['config_image_topic_width'] || !$this->request->post['config_image_topic_height']) {
|
| 699: | $json['error']['image_topic'] = $this->language->get('error_image_topic');
|
| 700: | }
|
| 701: |
|
| 702: | if (!$this->request->post['config_image_compare_width'] || !$this->request->post['config_image_compare_height']) {
|
| 703: | $json['error']['image_compare'] = $this->language->get('error_image_compare');
|
| 704: | }
|
| 705: |
|
| 706: | if (!$this->request->post['config_image_wishlist_width'] || !$this->request->post['config_image_wishlist_height']) {
|
| 707: | $json['error']['image_wishlist'] = $this->language->get('error_image_wishlist');
|
| 708: | }
|
| 709: |
|
| 710: | if (!$this->request->post['config_image_cart_width'] || !$this->request->post['config_image_cart_height']) {
|
| 711: | $json['error']['image_cart'] = $this->language->get('error_image_cart');
|
| 712: | }
|
| 713: |
|
| 714: | if (!$this->request->post['config_image_location_width'] || !$this->request->post['config_image_location_height']) {
|
| 715: | $json['error']['image_location'] = $this->language->get('error_image_location');
|
| 716: | }
|
| 717: |
|
| 718: | if (isset($json['error']) && !isset($json['error']['warning'])) {
|
| 719: | $json['error']['warning'] = $this->language->get('error_warning');
|
| 720: | }
|
| 721: |
|
| 722: | if (!$json) {
|
| 723: | $this->load->model('setting/setting');
|
| 724: | $this->load->model('setting/store');
|
| 725: |
|
| 726: | if (!$this->request->post['store_id']) {
|
| 727: | $json['store_id'] = $this->model_setting_store->addStore($this->request->post);
|
| 728: |
|
| 729: | $this->model_setting_setting->editSetting('config', $this->request->post, $json['store_id']);
|
| 730: | } else {
|
| 731: | $this->model_setting_store->editStore($this->request->post['store_id'], $this->request->post);
|
| 732: |
|
| 733: | $this->model_setting_setting->editSetting('config', $this->request->post, $this->request->post['store_id']);
|
| 734: | }
|
| 735: |
|
| 736: | $json['success'] = $this->language->get('text_success');
|
| 737: | }
|
| 738: |
|
| 739: | $this->response->addHeader('Content-Type: application/json');
|
| 740: | $this->response->setOutput(json_encode($json));
|
| 741: | }
|
| 742: |
|
| 743: | |
| 744: | |
| 745: | |
| 746: | |
| 747: |
|
| 748: | public function delete(): void {
|
| 749: | $this->load->language('setting/store');
|
| 750: |
|
| 751: | $json = [];
|
| 752: |
|
| 753: | if (isset($this->request->post['selected'])) {
|
| 754: | $selected = $this->request->post['selected'];
|
| 755: | } else {
|
| 756: | $selected = [];
|
| 757: | }
|
| 758: |
|
| 759: | if (!$this->user->hasPermission('modify', 'setting/store')) {
|
| 760: | $json['error'] = $this->language->get('error_permission');
|
| 761: | }
|
| 762: |
|
| 763: | $this->load->model('sale/order');
|
| 764: | $this->load->model('sale/subscription');
|
| 765: |
|
| 766: | foreach ($selected as $store_id) {
|
| 767: | if (!$store_id) {
|
| 768: | $json['error'] = $this->language->get('error_default');
|
| 769: | }
|
| 770: |
|
| 771: | $order_total = $this->model_sale_order->getTotalOrdersByStoreId($store_id);
|
| 772: |
|
| 773: | if ($order_total) {
|
| 774: | $json['error'] = sprintf($this->language->get('error_store'), $order_total);
|
| 775: | }
|
| 776: |
|
| 777: | $subscription_total = $this->model_sale_subscription->getTotalSubscriptionsByStoreId($store_id);
|
| 778: |
|
| 779: | if ($subscription_total) {
|
| 780: | $json['error'] = sprintf($this->language->get('error_store'), $subscription_total);
|
| 781: | }
|
| 782: | }
|
| 783: |
|
| 784: | if (!$json) {
|
| 785: | $this->load->model('setting/store');
|
| 786: | $this->load->model('setting/setting');
|
| 787: |
|
| 788: | foreach ($selected as $store_id) {
|
| 789: | $this->model_setting_store->deleteStore($store_id);
|
| 790: |
|
| 791: | $this->model_setting_setting->deleteSetting('config', $store_id);
|
| 792: | }
|
| 793: |
|
| 794: | $json['success'] = $this->language->get('text_success');
|
| 795: | }
|
| 796: |
|
| 797: | $this->response->addHeader('Content-Type: application/json');
|
| 798: | $this->response->setOutput(json_encode($json));
|
| 799: | }
|
| 800: | }
|
| 801: | |