@maks78945

Как вывести 404 по условию на странице с продуктами в OpenCard?

Добрый день, есть get параметр с номером страница, но проблема в то что если указать страницу 999999, он возвращается что товаров нет, как сделать что бы при запросе страницы на которой нет товаров возвращалась 404?
  • Вопрос задан
  • 555 просмотров
Решения вопроса 1
zoozag
@zoozag
Opencart
На примере 2.3:
ControllerProductCategory
Найти
if ($limit && ceil($product_total / $limit) > $page) {
			    $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1), true), 'next');
			}

добавить после
if ($limit && ceil($product_total / $limit) < $page) {
  $url = '';

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

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

	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'];
	}

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

	$data['breadcrumbs'][] = array(
		'text' => $this->language->get('text_error'),
		'href' => $this->url->link('product/category', $url)
	);

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

	$data['heading_title'] = $this->language->get('text_error');

	$data['text_error'] = $this->language->get('text_error');

	$data['button_continue'] = $this->language->get('button_continue');

	$data['continue'] = $this->url->link('common/home');

	$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');

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

	$this->response->setOutput($this->load->view('error/not_found', $data));
}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы