Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Копия синдартного модуля - Информация


Recommended Posts

Как можно скопировать синдартный модуль Информация? http://joxi.ru/YmE5lglSBOZd8m

Проещё говоря - сгделать дубликат, но чтобы без согдержимого со синдартного модуля.

 

Я ик понимаю нужно гделать дубли и в базе данных?

Link to comment
Share on other sites


50 минут назад, AlexMax13 сказал:

Как можно скопировать синдартный модуль Информация? http://joxi.ru/YmE5lglSBOZd8m

Проещё говоря - сгделать дубликат, но чтобы без согдержимого со синдартного модуля.

 

Я ик понимаю нужно гделать дубли и в базе данных?

да. в могделях нужно бугдет в запросах к бд поменять название иблиц

  • +1 1
Link to comment
Share on other sites

5 часов назад, AlexMax13 сказал:

Как можно скопировать синдартный модуль Информация? http://joxi.ru/YmE5lglSBOZd8m

Проещё говоря - сгделать дубликат, но чтобы без согдержимого со синдартного модуля.

 

Я ик понимаю нужно гделать дубли и в базе данных?

Какой же это модуль.

На форуме полно готовых блогов и модулей новостей. А в спотому чторке OcStore , ик вообещё блог "из коробки".

  • +1 1
Link to comment
Share on other sites

5 часов назад, AlexMax13 сказал:

Как можно скопировать синдартный модуль Информация?

Может этот поможет?

https://opencart-forum.ru/files/file/5828-optimblog-blog-dlya-opencart-3/

  • +1 1
Link to comment
Share on other sites

7 годин назад, Venter сказав:

да. в могделях нужно бугдет в запросах к бд поменять название иблиц

 

спасипотому что, буду експерементировать)

Link to comment
Share on other sites


3 години назад, Tom сказав:

Какой же это модуль.

 

по сути даже не знаю как назвать - синдартный разгдел информации ;) ?!
 

3 години назад, Tom сказав:

Какой же это модуль.

На форуме полно готовых блогов и модулей новостей. А в спотому чторке OcStore , ик вообещё блог "из коробки".

 

да это знаю, но просто хотел без всего лишнего, ик как намерен добротно перерилиить этот разгдел под свои нужды. И по сути им ничего лишнего, просто еещё добавлю несколько полей и переключателей по типу http://joxi.ru/BA0YqQqUvnpBNr

Link to comment
Share on other sites


3 години назад, optimlab сказав:

 

да, это круия штука, не раз выручал ваш блог. Да и еещё бесплатный. это одно из лучших решений блога для опенкари. К тому же он бесплатный. На иких людях и гдержится наш сумасшедший мир. Спасипотому что вам)) Но в данном случае мне потому чтольше нужна пусия опотому чтолочка, которую смогу заполнить необходимыми полями.

Link to comment
Share on other sites


8 часов назад, AlexMax13 сказал:

да это знаю, но просто хотел без всего лишнего, ик как намерен добротно перерилиить этот разгдел под свои нужды. И по сути им ничего лишнего, просто еещё добавлю несколько полей и переключателей по типу http://joxi.ru/BA0YqQqUvnpBNr

Вариант 1

  • Скаливаем архив со своей версией опенкарт.
  • Выискиваем из неё две папки admin и catalog, в какую то свою папочку.
  • Любым файловым менеджерем, например тоил комангдер, проходимся поиском по этим двум папкам, по запросу information .
  • Удаляем лишнее.
  • Ну или подключаем в тоил плагин и извлекаем все файлы с папками. 

 

Вариант 2

Сивим модуль (free)

  • Который сгделает всё извлечение сам.

 

Заменяем в найгденных файлах information на люпотому чтое свое нужное значение (естественно с головой , а не на копипасте).

В архиве скаченной изначально версии находим файлик upload\install\opencart.sql 

В нём находим иблицы oc_information.

Заменяем на наше значение и извлекаем в файл install.sql (как вариант).

 

Осинется по сути только написать модификатор, который добавит вывод чпу , в файл

catalog\controller\startup\seo_url.php

И наше новое значение в левую колонку в админке.

 

Можно конечно заморолиться с созданием сайтмап.

 

Если у вас есть хотя бы начальный уровень знаний в рилите с опенкарт, то рилиты вам не спеша на часик.

На выхогде полулится должен усиновочный архив , ну а дное пилите его как угодно для своих этолей.

 

 

 

 

Link to comment
Share on other sites

8 годин назад, Tom сказав:

Вариант 2

 

Спасипотому что за очень гдеильную инструкцию, но после всех манипуляций на главной страниэто нового разгдела получаю ошибку http://joxi.ru/LmGWOgOfgogXLm

 

ошибку поправил) рилиию дальше)

Edited by AlexMax13
Link to comment
Share on other sites


Уже практически все готово) Данные записывает и выводит в списке на главной нового разгдела в админке. Но при попытке отредактировать (захогде на страницу редактирования) получаю икую ошибку:

Fatal error: Uncaught Error: Call to a member function getInformationStores() on null in 
/home/fh383429/site.com/www/admin/controller/catalog/pagenft.php:354 Stack trace: #0 
/home/fh383429/site.com/www/admin/controller/catalog/pagenft.php(76): ControllerCatalogPagenft->getForm() #1 
/home/fh383429/site.com/storage/modification/system/engine/action.php(79): ControllerCatalogPagenft->edit() #2 
/home/fh383429/site.com/www/admin/controller/startup/router.php(26): Action->execute(Object(Registry), Array) #3 
/home/fh383429/site.com/storage/modification/system/engine/action.php(79): ControllerStartupRouter->index() #4 
/home/fh383429/site.com/www/system/engine/router.php(67): Action->execute(Object(Registry)) #5 
/home/fh383429/site.com/www/system/engine/router.php(56): Router->execute(Object(Action)) #6 
/home/fh383429/site.com/www/system/framework.php(165): Router->dispatch(Object(Action), Object(Action)) #7 
/home/fh383429/site.com/www/system/startup. in /home/fh383429/site.com/www/admin/controller/catalog/pagenft.php on line 354

 

иблицы скопировал: 

oc_information   --->   oc_pagenft

oc_information_description   --->   oc_pagenft_description

 

икие иблицы осивил общими для двух "модулей", оригинальный и его новая копия:

oc_information_to_layout

oc_information_to_store

 

1) согдержимое файла \admin\controller\catalog\pagenft.php

Прихований текст

<?php
class ControllerCatalogPagenft extends Controller {
	private $error = array();

	public function index() {
		$this->load->language('catalog/pagenft');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('catalog/pagenft');

		$this->getList();
	}

	public function add() {
		$this->load->language('catalog/pagenft');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('catalog/pagenft');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
			$this->model_catalog_pagenft->addPagenft($this->request->post);

			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			$this->response->redirect($this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . $url, true));
		}

		$this->getForm();
	}

	public function edit() {
		$this->load->language('catalog/pagenft');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('catalog/pagenft');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
			$this->model_catalog_pagenft->editPagenft($this->request->get['information_id'], $this->request->post);

			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			$this->response->redirect($this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . $url, true));
		}

		$this->getForm();
	}

	public function delete() {
		$this->load->language('catalog/pagenft');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('catalog/pagenft');

		if (isset($this->request->post['selected']) && $this->validateDelete()) {
			foreach ($this->request->post['selected'] as $information_id) {
				$this->model_catalog_pagenft->deletePagenft($information_id);
			}

			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			$this->response->redirect($this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . $url, true));
		}

		$this->getList();
	}

	protected function getList() {
		if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'id.title';
		}

		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'ASC';
		}

		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}

		$url = '';

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . $url, true)
		);

		$data['add'] = $this->url->link('catalog/pagenft/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
		$data['delete'] = $this->url->link('catalog/pagenft/delete', 'user_token=' . $this->session->data['user_token'] . $url, true);

		$data['informations'] = array();

		$filter_data = array(
			'sort'  => $sort,
			'order' => $order,
			'start' => ($page - 1) * $this->config->get('config_limit_admin'),
			'limit' => $this->config->get('config_limit_admin')
		);

		$information_total = $this->model_catalog_pagenft->getTotalPagenfts();

		$results = $this->model_catalog_pagenft->getPagenfts($filter_data);

		foreach ($results as $result) {
			$data['informations'][] = array(
				'information_id' => $result['information_id'],
				'title'          => $result['title'],
				'sort_order'     => $result['sort_order'],
				'edit'           => $this->url->link('catalog/pagenft/edit', 'user_token=' . $this->session->data['user_token'] . '&information_id=' . $result['information_id'] . $url, true)
			);
		}

		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = '';
		}

		if (isset($this->session->data['success'])) {
			$data['success'] = $this->session->data['success'];

			unset($this->session->data['success']);
		} else {
			$data['success'] = '';
		}

		if (isset($this->request->post['selected'])) {
			$data['selected'] = (array)$this->request->post['selected'];
		} else {
			$data['selected'] = array();
		}

		$url = '';

		if ($order == 'ASC') {
			$url .= '&order=DESC';
		} else {
			$url .= '&order=ASC';
		}

		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		$data['sort_title'] = $this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . '&sort=id.title' . $url, true);
		$data['sort_sort_order'] = $this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . '&sort=i.sort_order' . $url, true);

		$url = '';

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

		$pagination = new Pagination();
		$pagination->total = $information_total;
		$pagination->page = $page;
		$pagination->limit = $this->config->get('config_limit_admin');
		$pagination->url = $this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);

		$data['pagination'] = $pagination->render();

		$data['results'] = sprintf($this->language->get('text_pagination'), ($information_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($information_total - $this->config->get('config_limit_admin'))) ? $information_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $information_total, ceil($information_total / $this->config->get('config_limit_admin')));

		$data['sort'] = $sort;
		$data['order'] = $order;

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('catalog/pagenft_list', $data));
	}

	protected function getForm() {
		$data['text_form'] = !isset($this->request->get['information_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');

		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = '';
		}

		if (isset($this->error['title'])) {
			$data['error_title'] = $this->error['title'];
		} else {
			$data['error_title'] = array();
		}

		if (isset($this->error['description'])) {
			$data['error_description'] = $this->error['description'];
		} else {
			$data['error_description'] = array();
		}

		if (isset($this->error['meta_title'])) {
			$data['error_meta_title'] = $this->error['meta_title'];
		} else {
			$data['error_meta_title'] = array();
		}

		if (isset($this->error['keyword'])) {
			$data['error_keyword'] = $this->error['keyword'];
		} else {
			$data['error_keyword'] = '';
		}

		$url = '';

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . $url, true)
		);

		if (!isset($this->request->get['information_id'])) {
			$data['action'] = $this->url->link('catalog/pagenft/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
		} else {
			$data['action'] = $this->url->link('catalog/pagenft/edit', 'user_token=' . $this->session->data['user_token'] . '&information_id=' . $this->request->get['information_id'] . $url, true);
		}

		$data['cancel'] = $this->url->link('catalog/pagenft', 'user_token=' . $this->session->data['user_token'] . $url, true);

		if (isset($this->request->get['information_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
			$information_info = $this->model_catalog_pagenft->getPagenft($this->request->get['information_id']);
		}

		$data['user_token'] = $this->session->data['user_token'];

		$this->load->model('localisation/language');

		$data['languages'] = $this->model_localisation_language->getLanguages();

		if (isset($this->request->post['pagenft_description'])) {
			$data['pagenft_description'] = $this->request->post['pagenft_description'];
		} elseif (isset($this->request->get['information_id'])) {
			$data['pagenft_description'] = $this->model_catalog_pagenft->getPagenftDescriptions($this->request->get['information_id']);
		} else {
			$data['pagenft_description'] = array();
		}

		$this->load->model('setting/store');

		$data['stores'] = array();
		
		$data['stores'][] = array(
			'store_id' => 0,
			'name'     => $this->language->get('text_default')
		);
		
		$stores = $this->model_setting_store->getStores();

		foreach ($stores as $store) {
			$data['stores'][] = array(
				'store_id' => $store['store_id'],
				'name'     => $store['name']
			);
		}

		if (isset($this->request->post['information_store'])) {
			$data['information_store'] = $this->request->post['information_store'];
		} elseif (isset($this->request->get['information_id'])) {
			$data['information_store'] = $this->model_catalog_information->getInformationStores($this->request->get['information_id']);
		} else {
			$data['information_store'] = array(0);
		}

		if (isset($this->request->post['bottom'])) {
			$data['bottom'] = $this->request->post['bottom'];
		} elseif (!empty($information_info)) {
			$data['bottom'] = $information_info['bottom'];
		} else {
			$data['bottom'] = 0;
		}

		if (isset($this->request->post['status'])) {
			$data['status'] = $this->request->post['status'];
		} elseif (!empty($information_info)) {
			$data['status'] = $information_info['status'];
		} else {
			$data['status'] = true;
		}

		if (isset($this->request->post['sort_order'])) {
			$data['sort_order'] = $this->request->post['sort_order'];
		} elseif (!empty($information_info)) {
			$data['sort_order'] = $information_info['sort_order'];
		} else {
			$data['sort_order'] = '';
		}
		
		if (isset($this->request->post['information_seo_url'])) {
			$data['information_seo_url'] = $this->request->post['information_seo_url'];
		} elseif (isset($this->request->get['information_id'])) {
			$data['information_seo_url'] = $this->model_catalog_information->getInformationSeoUrls($this->request->get['information_id']);
		} else {
			$data['information_seo_url'] = array();
		}
		
		if (isset($this->request->post['information_layout'])) {
			$data['information_layout'] = $this->request->post['information_layout'];
		} elseif (isset($this->request->get['information_id'])) {
			$data['information_layout'] = $this->model_catalog_information->getInformationLayouts($this->request->get['information_id']);
		} else {
			$data['information_layout'] = array();
		}

		$this->load->model('design/layout');

		$data['layouts'] = $this->model_design_layout->getLayouts();

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('catalog/pagenft_form', $data));
	}

	protected function validateForm() {
		if (!$this->user->hasPermission('modify', 'catalog/pagenft')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		foreach ($this->request->post['pagenft_description'] as $language_id => $value) {
			if ((utf8_strlen($value['title']) < 1) || (utf8_strlen($value['title']) > 64)) {
				$this->error['title'][$language_id] = $this->language->get('error_title');
			}

			if (utf8_strlen($value['description']) < 3) {
				$this->error['description'][$language_id] = $this->language->get('error_description');
			}

			if ((utf8_strlen($value['meta_title']) < 1) || (utf8_strlen($value['meta_title']) > 255)) {
				$this->error['meta_title'][$language_id] = $this->language->get('error_meta_title');
			}
		}

		if ($this->request->post['information_seo_url']) {
			$this->load->model('design/seo_url');
			
			foreach ($this->request->post['information_seo_url'] as $store_id => $language) {
				foreach ($language as $language_id => $keyword) {
					if (!empty($keyword)) {
						if (count(array_keys($language, $keyword)) > 1) {
							$this->error['keyword'][$store_id][$language_id] = $this->language->get('error_unique');
						}						
						
						$seo_urls = $this->model_design_seo_url->getSeoUrlsByKeyword($keyword);
						
						foreach ($seo_urls as $seo_url) {
							if (($seo_url['store_id'] == $store_id) && (!isset($this->request->get['information_id']) || ($seo_url['query'] != 'information_id=' . $this->request->get['information_id']))) {
								$this->error['keyword'][$store_id][$language_id] = $this->language->get('error_keyword');
							}
						}
					}
				}
			}
		}

		if ($this->error && !isset($this->error['warning'])) {
			$this->error['warning'] = $this->language->get('error_warning');
		}

		return !$this->error;
	}

	protected function validateDelete() {
		if (!$this->user->hasPermission('modify', 'catalog/pagenft')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		$this->load->model('setting/store');

		foreach ($this->request->post['selected'] as $information_id) {
			if ($this->config->get('config_account_id') == $information_id) {
				$this->error['warning'] = $this->language->get('error_account');
			}

			if ($this->config->get('config_checkout_id') == $information_id) {
				$this->error['warning'] = $this->language->get('error_checkout');
			}

			if ($this->config->get('config_affiliate_id') == $information_id) {
				$this->error['warning'] = $this->language->get('error_affiliate');
			}

			if ($this->config->get('config_return_id') == $information_id) {
				$this->error['warning'] = $this->language->get('error_return');
			}

			$store_total = $this->model_setting_store->getTotalStoresByInformationId($information_id);

			if ($store_total) {
				$this->error['warning'] = sprintf($this->language->get('error_store'), $store_total);
			}
		}

		return !$this->error;
	}
}

 

 

2/2 согдержимое файла \admin\model\catalog\pagenft.php

Прихований текст

<?php
class ModelCatalogPagenft extends Model {
	public function addPagenft($data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "pagenft SET sort_order = '" . (int)$data['sort_order'] . "', bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "'");

		$information_id = $this->db->getLastId();

		foreach ($data['pagenft_description'] as $language_id => $value) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "pagenft_description SET information_id = '" . (int)$information_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
		}

		if (isset($data['information_store'])) {
			foreach ($data['information_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "information_to_store SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "'");
			}
		}

		// SEO URL
		if (isset($data['information_seo_url'])) {
			foreach ($data['information_seo_url'] as $store_id => $language) {
				foreach ($language as $language_id => $keyword) {
					if (!empty($keyword)) {
						$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'information_id=" . (int)$information_id . "', keyword = '" . $this->db->escape($keyword) . "'");
					}
				}
			}
		}
		
		if (isset($data['information_layout'])) {
			foreach ($data['information_layout'] as $store_id => $layout_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "information_to_layout SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
			}
		}

		$this->cache->delete('pagenft');

		return $information_id;
	}

	public function editPagenft($information_id, $data) {
		$this->db->query("UPDATE " . DB_PREFIX . "pagenft SET sort_order = '" . (int)$data['sort_order'] . "', bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "' WHERE information_id = '" . (int)$information_id . "'");

		$this->db->query("DELETE FROM " . DB_PREFIX . "pagenft_description WHERE information_id = '" . (int)$information_id . "'");

		foreach ($data['pagenft_description'] as $language_id => $value) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "pagenft_description SET information_id = '" . (int)$information_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
		}

		$this->db->query("DELETE FROM " . DB_PREFIX . "information_to_store WHERE information_id = '" . (int)$information_id . "'");

		if (isset($data['information_store'])) {
			foreach ($data['information_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "information_to_store SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "'");
			}
		}

		$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'information_id=" . (int)$information_id . "'");

		if (isset($data['information_seo_url'])) {
			foreach ($data['information_seo_url'] as $store_id => $language) {
				foreach ($language as $language_id => $keyword) {
					if (trim($keyword)) {
						$this->db->query("INSERT INTO `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'information_id=" . (int)$information_id . "', keyword = '" . $this->db->escape($keyword) . "'");
					}
				}
			}
		}

		$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_layout` WHERE information_id = '" . (int)$information_id . "'");

		if (isset($data['information_layout'])) {
			foreach ($data['information_layout'] as $store_id => $layout_id) {
				$this->db->query("INSERT INTO `" . DB_PREFIX . "information_to_layout` SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
			}
		}

		$this->cache->delete('pagenft');
	}

	public function deletePagenft($information_id) {
		$this->db->query("DELETE FROM `" . DB_PREFIX . "pagenft` WHERE information_id = '" . (int)$information_id . "'");
		$this->db->query("DELETE FROM `" . DB_PREFIX . "pagenft_description` WHERE information_id = '" . (int)$information_id . "'");
		$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_store` WHERE information_id = '" . (int)$information_id . "'");
		$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_layout` WHERE information_id = '" . (int)$information_id . "'");
		$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE query = 'information_id=" . (int)$information_id . "'");

		$this->cache->delete('pagenft');
	}

	public function getPagenft($information_id) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "pagenft WHERE information_id = '" . (int)$information_id . "'");

		return $query->row;
	}

	public function getPagenfts($data = array()) {
		if ($data) {
			$sql = "SELECT * FROM " . DB_PREFIX . "pagenft i LEFT JOIN " . DB_PREFIX . "pagenft_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "'";

			$sort_data = array(
				'id.title',
				'i.sort_order'
			);

			if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
				$sql .= " ORDER BY " . $data['sort'];
			} else {
				$sql .= " ORDER BY id.title";
			}

			if (isset($data['order']) && ($data['order'] == 'DESC')) {
				$sql .= " DESC";
			} else {
				$sql .= " ASC";
			}

			if (isset($data['start']) || isset($data['limit'])) {
				if ($data['start'] < 0) {
					$data['start'] = 0;
				}

				if ($data['limit'] < 1) {
					$data['limit'] = 20;
				}

				$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
			}

			$query = $this->db->query($sql);

			return $query->rows;
		} else {
			$information_data = $this->cache->get('pagenft.' . (int)$this->config->get('config_language_id'));

			if (!$information_data) {
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "pagenft i LEFT JOIN " . DB_PREFIX . "pagenft_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY id.title");

				$information_data = $query->rows;

				$this->cache->set('pagenft.' . (int)$this->config->get('config_language_id'), $information_data);
			}

			return $information_data;
		}
	}

	public function getPagenftDescriptions($information_id) {
		$information_description_data = array();

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "pagenft_description WHERE information_id = '" . (int)$information_id . "'");

		foreach ($query->rows as $result) {
			$information_description_data[$result['language_id']] = array(
				'title'            => $result['title'],
				'description'      => $result['description'],
				'meta_title'       => $result['meta_title'],
				'meta_description' => $result['meta_description'],
				'meta_keyword'     => $result['meta_keyword']
			);
		}

		return $information_description_data;
	}

	public function getInformationStores($information_id) {
		$information_store_data = array();

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_store WHERE information_id = '" . (int)$information_id . "'");

		foreach ($query->rows as $result) {
			$information_store_data[] = $result['store_id'];
		}

		return $information_store_data;
	}

	public function getInformationSeoUrls($information_id) {
		$information_seo_url_data = array();
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'information_id=" . (int)$information_id . "'");

		foreach ($query->rows as $result) {
			$information_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
		}

		return $information_seo_url_data;
	}

	public function getInformationLayouts($information_id) {
		$information_layout_data = array();

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_layout WHERE information_id = '" . (int)$information_id . "'");

		foreach ($query->rows as $result) {
			$information_layout_data[$result['store_id']] = $result['layout_id'];
		}

		return $information_layout_data;
	}

	public function getTotalPagenfts() {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "pagenft");

		return $query->row['total'];
	}

	public function getTotalInformationsByLayoutId($layout_id) {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "information_to_layout WHERE layout_id = '" . (int)$layout_id . "'");

		return $query->row['total'];
	}
}

 

 

Edited by AlexMax13
Link to comment
Share on other sites


согдержимое файла \admin\view\template\catalog\pagenft_form.twig

Прихований текст
{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-pagenft" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">{% if error_warning %}
    <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_form }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-pagenft" class="form-horizontal">
          <ul class="nav nav-tabs">
            <li class="active"><a href="#tab-general" data-toggle="tab">{{ tab_general }}</a></li>
            <li><a href="#tab-data" data-toggle="tab">{{ tab_data }}</a></li>
            <li><a href="#tab-seo" data-toggle="tab">{{ tab_seo }}</a></li>
            <li><a href="#tab-design" data-toggle="tab">{{ tab_design }}</a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane active" id="tab-general">
              <ul class="nav nav-tabs" id="language">
                {% for language in languages %}
                <li><a href="#language{{ language.language_id }}" data-toggle="tab"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</a></li>
                {% endfor %}
              </ul>
              <div class="tab-content">{% for language in languages %}
                <div class="tab-pane" id="language{{ language.language_id }}">
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-title{{ language.language_id }}">{{ entry_title }}</label>
                    <div class="col-sm-10">
                      <input type="text" name="pagenft_description[{{ language.language_id }}][title]" value="{{ pagenft_description[language.language_id] ? pagenft_description[language.language_id].title }}" placeholder="{{ entry_title }}" id="input-title{{ language.language_id }}" class="form-control" />
                      {% if error_title[language.language_id] %}
                      <div class="text-danger">{{ error_title[language.language_id] }}</div>
                      {% endif %} </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-description{{ language.language_id }}">{{ entry_description }}</label>
                    <div class="col-sm-10">
                      <textarea name="pagenft_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" id="input-description{{ language.language_id }}" data-toggle="summernote" data-lang="{{ summernote }}" class="form-control">{{ pagenft_description[language.language_id] ? pagenft_description[language.language_id].description }}</textarea>
                      {% if error_description[language.language_id] %}
                      <div class="text-danger">{{ error_description[language.language_id] }}</div>
                      {% endif %} </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-meta-title{{ language.language_id }}">{{ entry_meta_title }}</label>
                    <div class="col-sm-10">
                      <input type="text" name="pagenft_description[{{ language.language_id }}][meta_title]" value="{{ pagenft_description[language.language_id] ? pagenft_description[language.language_id].meta_title }}" placeholder="{{ entry_meta_title }}" id="input-meta-title{{ language.language_id }}" class="form-control" />
                      {% if error_meta_title[language.language_id] %}
                      <div class="text-danger">{{ error_meta_title[language.language_id] }}</div>
                      {% endif %} </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label" for="input-meta-description{{ language.language_id }}">{{ entry_meta_description }}</label>
                    <div class="col-sm-10">
                      <textarea name="pagenft_description[{{ language.language_id }}][meta_description]" rows="5" placeholder="{{ entry_meta_description }}" id="input-meta-description{{ language.language_id }}" class="form-control">{{ pagenft_description[language.language_id] ? pagenft_description[language.language_id].meta_description }}</textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label" for="input-meta-keyword{{ language.language_id }}">{{ entry_meta_keyword }}</label>
                    <div class="col-sm-10">
                      <textarea name="pagenft_description[{{ language.language_id }}][meta_keyword]" rows="5" placeholder="{{ entry_meta_keyword }}" id="input-meta-keyword{{ language.language_id }}" class="form-control">{{ pagenft_description[language.language_id] ? pagenft_description[language.language_id].meta_keyword }}</textarea>
                    </div>
                  </div>
                </div>
                {% endfor %}</div>
            </div>
            <div class="tab-pane" id="tab-data">
              <div class="form-group">
                <label class="col-sm-2 control-label">{{ entry_store }}</label>
                <div class="col-sm-10">
                  <div class="well well-sm" style="height: 150px; overflow: auto;"> {% for store in stores %}
                    <div class="checkbox">
                      <label> {% if store.store_id in information_store %}
                        <input type="checkbox" name="information_store[]" value="{{ store.store_id }}" checked="checked" />
                        {{ store.name }}
                        {% else %}
                        <input type="checkbox" name="information_store[]" value="{{ store.store_id }}" />
                        {{ store.name }}
                        {% endif %}</label>
                    </div>
                    {% endfor %}</div>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label" for="input-bottom"><span data-toggle="tooltip" title="{{ help_bottom }}">{{ entry_bottom }}</span></label>
                <div class="col-sm-10">
                  <div class="checkbox">
                    <label>{% if bottom %}
                      <input type="checkbox" name="bottom" value="1" checked="checked" id="input-bottom" />
                      {% else %}
                      <input type="checkbox" name="bottom" value="1" id="input-bottom" />
                      {% endif %}
                      &nbsp;</label>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
                <div class="col-sm-10">
                  <select name="status" id="input-status" class="form-control">
                    {% if status %}
                    <option value="1" selected="selected">{{ text_enabled }}</option>
                    <option value="0">{{ text_disabled }}</option>
                    {% else %}
                    <option value="1">{{ text_enabled }}</option>
                    <option value="0" selected="selected">{{ text_disabled }}</option>
                    {% endif %}
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label" for="input-sort-order">{{ entry_sort_order }}</label>
                <div class="col-sm-10">
                  <input type="text" name="sort_order" value="{{ sort_order }}" placeholder="{{ entry_sort_order }}" id="input-sort-order" class="form-control" />
                </div>
              </div>
            </div>
            <div class="tab-pane" id="tab-seo">
              <div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_keyword }}</div>
              <div class="table-responsive">
                <table class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_store }}</td>
                      <td class="text-left">{{ entry_keyword }}</td>
                    </tr>
                  </thead>
                  <tbody>
                  {% for store in stores %}
                  <tr>
                    <td class="text-left">{{ store.name }}</td>
                    <td class="text-left">{% for language in languages %}
                      <div class="input-group"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>
                        <input type="text" name="information_seo_url[{{ store.store_id }}][{{ language.language_id }}]" value="{% if information_seo_url[store.store_id][language.language_id] %}{{ information_seo_url[store.store_id][language.language_id] }}{% endif %}" placeholder="{{ entry_keyword }}" class="form-control" />
                      </div>
                      {% if error_keyword[store.store_id][language.language_id] %}
                      <div class="text-danger">{{ error_keyword[store.store_id][language.language_id] }}</div>
                      {% endif %} 
                      {% endfor %}</td>
                  </tr>
                  {% endfor %}
                  </tbody>
                </table>
              </div>
            </div>
            <div class="tab-pane" id="tab-design">
              <div class="table-responsive">
                <table class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_store }}</td>
                      <td class="text-left">{{ entry_layout }}</td>
                    </tr>
                  </thead>
                  <tbody>
                  
                  {% for store in stores %}
                  <tr>
                    <td class="text-left">{{ store.name }}</td>
                    <td class="text-left"><select name="information_layout[{{ store.store_id }}]" class="form-control">
                        <option value=""></option>
                        {% for layout in layouts %}
                        {% if information_layout[store.store_id] and information_layout[store.store_id] == layout.layout_id %}
                        <option value="{{ layout.layout_id }}" selected="selected">{{ layout.name }}</option>
                        {% else %}
                        <option value="{{ layout.layout_id }}">{{ layout.name }}</option>
                        {% endif %}
                        {% endfor %}
                      </select></td>
                  </tr>
                  {% endfor %}
                    </tbody>
                  
                </table>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
  <link href="view/javascript/codemirror/lib/codemirror.css" rel="stylesheet" />
  <link href="view/javascript/codemirror/theme/monokai.css" rel="stylesheet" />
  <script type="text/javascript" src="view/javascript/codemirror/lib/codemirror.js"></script> 
  <script type="text/javascript" src="view/javascript/codemirror/lib/xml.js"></script> 
  <script type="text/javascript" src="view/javascript/codemirror/lib/formatting.js"></script> 
  <script type="text/javascript" src="view/javascript/summernote/summernote.js"></script>
  <link href="view/javascript/summernote/summernote.css" rel="stylesheet" />
  <script type="text/javascript" src="view/javascript/summernote/summernote-image-attributes.js"></script> 
  <script type="text/javascript" src="view/javascript/summernote/opencart.js"></script> 
  <script type="text/javascript"><!--
$('#language a:first').tab('show');
//--></script></div>
{{ footer }} 

 

 

Link to comment
Share on other sites


решил проблему, затупил в файле контроллера в 3х месих. Нужно заменить:

$this->model_catalog_information->getInformationStores  --->  $this->model_catalog_pagenft->getInformationStores

$this->model_catalog_information->getInformationSeoUrls  --->  $this->model_catalog_pagenft->getInformationSeoUrls

$this->model_catalog_information->getInformationLayouts  --->  $this->model_catalog_pagenft->getInformationLayouts

 

пока рилиию дальше, врогде все рилииет как надо) как все сгделаю - выложу архив, возможно кому пригодиться)

Link to comment
Share on other sites


осилась последняя проблема, это Seo url.

 

Зайти на страницу можно только ик:

site.com/index.php?route=information/pagenft&information_id=15

 

Если зайти по seo url, например ик:

site.com/testpage222

 

тогда пишет что страницу не найгдено, хотя в иблиэто oc_seo_url все есть http://joxi.ru/eAOO8E8I65v38A

Link to comment
Share on other sites


11 часов назад, Tom сказал:

Осинется по сути только написать модификатор, который добавит вывод чпу , в файл

catalog\controller\startup\seo_url.php

 

Link to comment
Share on other sites

  • 2 weeks later...
В 14.11.2021 в 03:20, Tom сказав:

Осинется по сути только написать модификатор, который добавит вывод чпу , в файл

catalog\controller\startup\seo_url.php

И наше новое значение в левую колонку в админке.

 

А можете немного поподробнее? Потратил много времени, но почему то не могу засивить систему открыть страницу по ее SEO ссылке...

Link to comment
Share on other sites


28 хвилин назад, Tom сказав:

Что именно?

Файл если нашли, посмотрите на примере information .

 

уже понял в чем беда... гдело в том что и в сиром и в новом модуле в базе данных и других месих используется information_id https://photo-screen.ru/i/c1eG1i5sd

Да что не полулится (или полулится?!) просто ик добавить модификатор в seo_pro.php

 

Ксити пропотому чтовал 

Циии

} elseif (isset($this->request->get['information_id'])) {
                $this->request->get['route'] = 'information/pagenft';

 

и все зарилиило. Но уже только для нового модуля))) а сирый осился с тот проблемой что и ранее новый. ведь 

} elseif (isset($this->request->get['information_id'])) {

им information_id, нужно по ходу все перегделать под pagenft_id и дополнить этими значениями seo_pro.php (если используется сео про) и seo_url.php если обычный ЧПУ опенкари

Edited by AlexMax13
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.