Opencart 1.5.1.3: выдача HTTP/404 для товаров, которые отключены администратором
В Опенкарт, если товар отключен, а внешняя ссылка на него где-то сохранилась, при переходе по ней будет отдан HTTP код 200 (OK) вместо более правильного 404 (Not Found).
Эту ситуацию исправляет одна строчка, см. патч ниже.
Спасибо: molotochek, см. http://opencartforum.ru/topic/418-%d0%bd%d0%b5-%d1%80%d0%b0%d0%b1%d0%be%d1%82%d0%b0%d0%b5%d1%82-404/page__view__findpost__p__46795
commit 6ef5a39e9e82c4e82901ce47d5304313867afb83
Author: Ruslan Brest <rb@labtodo.com>
Date: Tue Feb 21 17:03:00 2012 +0200
[!] HTTP/200 => HTTP/404 для товаров, которые отключены администратором
и других страниц с ненайденными сущностями
by: molotochek
http://opencartforum.ru/topic/418-%d0%bd%d0%b5-%d1%80%d0%b0%d0%b1%d0%be%d1%82%d0%b0%d0%b5%d1%82-404/page__view__findpost__p__46795
diff --git a/upload/catalog/controller/product/product.php b/upload/catalog/controller/product/product.php
index c39ad77..c5579db 100644
--- a/upload/catalog/controller/product/product.php
+++ b/upload/catalog/controller/product/product.php
@@ -414,15 +414,13 @@ class ControllerProductProduct extends Controller {
);
$this->document->setTitle($this->language->get('text_error'));
-
$this->data['heading_title'] = $this->language->get('text_error');
-
$this->data['text_error'] = $this->language->get('text_error');
-
$this->data['button_continue'] = $this->language->get('button_continue');
-
$this->data['continue'] = $this->url->link('common/home');
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
+
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
diff --git a/upload/catalog/controller/account/download.php b/upload/catalog/controller/account/download.php
index 7b736d2..4cb0a0d 100644
--- a/upload/catalog/controller/account/download.php
+++ b/upload/catalog/controller/account/download.php
@@ -120,12 +120,11 @@ class ControllerAccountDownload extends Controller {
$this->response->setOutput($this->render());
} else {
$this->data['heading_title'] = $this->language->get('heading_title');
-
$this->data['text_error'] = $this->language->get('text_empty');
-
$this->data['button_continue'] = $this->language->get('button_continue');
-
$this->data['continue'] = $this->url->link('account/account', '', 'SSL');
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/controller/account/order.php b/upload/catalog/controller/account/order.php
index cb49bef..5006970 100644
--- a/upload/catalog/controller/account/order.php
+++ b/upload/catalog/controller/account/order.php
@@ -434,6 +434,8 @@ class ControllerAccountOrder extends Controller {
);
$this->data['continue'] = $this->url->link('account/order', '', 'SSL');
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/controller/account/return.php b/upload/catalog/controller/account/return.php
index 1575ff0..b9add37 100644
--- a/upload/catalog/controller/account/return.php
+++ b/upload/catalog/controller/account/return.php
@@ -283,12 +283,11 @@ class ControllerAccountReturn extends Controller {
);
$this->data['heading_title'] = $this->language->get('text_return');
-
$this->data['text_error'] = $this->language->get('text_error');
-
$this->data['button_continue'] = $this->language->get('button_continue');
-
$this->data['continue'] = $this->url->link('account/return', '', 'SSL');
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/controller/checkout/cart.php b/upload/catalog/controller/checkout/cart.php
index afc8660..964c180 100644
--- a/upload/catalog/controller/checkout/cart.php
+++ b/upload/catalog/controller/checkout/cart.php
@@ -277,12 +277,11 @@ class ControllerCheckoutCart extends Controller {
$this->response->setOutput($this->render());
} else {
$this->data['heading_title'] = $this->language->get('heading_title');
-
$this->data['text_error'] = $this->language->get('text_empty');
-
$this->data['button_continue'] = $this->language->get('button_continue');
-
$this->data['continue'] = $this->url->link('common/home');
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/controller/error/not_found.php b/upload/catalog/controller/error/not_found.php
index 251a745..ab0758a 100644
--- a/upload/catalog/controller/error/not_found.php
+++ b/upload/catalog/controller/error/not_found.php
@@ -22,15 +22,12 @@ class ControllerErrorNotFound extends Controller {
}
$this->data['heading_title'] = $this->language->get('heading_title');
-
$this->data['text_error'] = $this->language->get('text_error');
-
$this->data['button_continue'] = $this->language->get('button_continue');
+ $this->data['continue'] = $this->url->link('common/home');
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
- $this->data['continue'] = $this->url->link('common/home');
-
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
diff --git a/upload/catalog/controller/information/information.php b/upload/catalog/controller/information/information.php
index e3b52ce..38df1c7 100644
--- a/upload/catalog/controller/information/information.php
+++ b/upload/catalog/controller/information/information.php
@@ -62,14 +62,12 @@ class ControllerInformationInformation extends Controller {
);
$this->document->setTitle($this->language->get('text_error'));
-
$this->data['heading_title'] = $this->language->get('text_error');
-
$this->data['text_error'] = $this->language->get('text_error');
-
$this->data['button_continue'] = $this->language->get('button_continue');
-
$this->data['continue'] = $this->url->link('common/home');
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/controller/product/category.php b/upload/catalog/controller/product/category.php
index f30cb53..4ffea91 100644
--- a/upload/catalog/controller/product/category.php
+++ b/upload/catalog/controller/product/category.php
@@ -379,14 +379,12 @@ class ControllerProductCategory extends Controller {
);
$this->document->setTitle($this->language->get('text_error'));
-
$this->data['heading_title'] = $this->language->get('text_error');
-
$this->data['text_error'] = $this->language->get('text_error');
-
$this->data['button_continue'] = $this->language->get('button_continue');
-
$this->data['continue'] = $this->url->link('common/home');
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/controller/product/manufacturer.php b/upload/catalog/controller/product/manufacturer.php
index 7dd5359..3ce6a78 100644
--- a/upload/catalog/controller/product/manufacturer.php
+++ b/upload/catalog/controller/product/manufacturer.php
@@ -414,14 +414,12 @@ class ControllerProductManufacturer extends Controller {
);
$this->document->setTitle($this->language->get('text_error'));
-
$this->data['heading_title'] = $this->language->get('text_error');
-
$this->data['text_error'] = $this->language->get('text_error');
-
$this->data['button_continue'] = $this->language->get('button_continue');
-
$this->data['continue'] = $this->url->link('common/home');
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/controller/product/shoppica.php b/upload/catalog/controller/product/shoppica.php
index cf31414..0eb7eb0 100644
--- a/upload/catalog/controller/product/shoppica.php
+++ b/upload/catalog/controller/product/shoppica.php
@@ -338,6 +338,8 @@ class ControllerProductShoppica extends Controller
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
+
+ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
diff --git a/upload/catalog/model/checkout/order.php b/upload/catalog/model/checkout/order.php
index 8e8d414..afeb625 100644
--- a/upload/catalog/model/checkout/order.php
+++ b/upload/catalog/model/checkout/order.php
@@ -566,4 +566,4 @@ class ModelCheckoutOrder extends Model {
}
}
}
-?>
+?>
\ No newline at end of file
Еще записи по теме
- Opencart 1.5.1.2: Модуль категорий: третий уровень (без оптимизации запросов)
- Opencart 1.5.x (catalog): как сделать, чтобы модуль категорий показывал все подкатегории
- Opencart 1.5.1.3: добавляем главную страницу в sitemap.xml
- Opencart 1.5.1.3 - не отображаются заказы в админке
- Opencart: чем отличаются купоны и подарочные сертификаты?
- Убираем ограничение 999.99 на вес и размеры в Opencart
- Изменяем длину описаний товаров в каталоге OpenCart 1.5.x




Оставьте комментарий!