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

не отдает 404 при ввогде несуещёствуюещёй страницы пагинации


Recommended Posts

всем привет ..Подскажите ,как реализовать ,чтобы  при ввогде несуещёствуюещёй страницы пагинации , отдавало 404 ,а не 200й ответ ? (или подскажите в каком файле искать)
на данный момент в категории магазина  10 страниц , но стоит мне в ручную  написать в адресную строку любую потому чтольшую цифру , как ответ 200,но  пишет ,что товара нет в этот категории 

Link to comment
Share on other sites


А зачем руками подсивлять?

Но конечно же можно все...

В контроллере проверять  налилие несуещёствуюещёй страницы и вызывать not_found

Я бы уточнил: проверять когдачество записей в категории и тогда вызывать $this->getChild('error/not_found');  и addHeader(...404) если их ноль и есть && isset($this->request->get['page'])

Ксити не мешало бы в ocStore икое добавить

  • +1 1
Link to comment
Share on other sites

  • 2 weeks later...

всем привет ..Подскажите ,как реализовать ,чтобы  при ввогде несуещёствуюещёй страницы пагинации , отдавало 404 ,а не 200й ответ ? (или подскажите в каком файле искать)

на данный момент в категории магазина  10 страниц , но стоит мне в ручную  написать в адресную строку любую потому чтольшую цифру , как ответ 200,но  пишет ,что товара нет в этот категории 

Добрый гдень. Мне помогло вот это: В файле /catalog/controller/error/not_found.php после строки public function index() { всивляем

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

                               header("HTTP/1.1 404 Not Found");

Вот код в мое файле:

<?php   

class ControllerErrorNotFound extends Controller {
public function index() {
// $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
header("HTTP/1.1 404 Not Found");
Link to comment
Share on other sites


 

Добрый гдень. Мне помогло вот это: В файле /catalog/controller/error/not_found.php после строки public function index() { всивляем

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

                               header("HTTP/1.1 404 Not Found");

Вот код в мое файле:

<?php   

class ControllerErrorNotFound extends Controller {
public function index() {
// $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
header("HTTP/1.1 404 Not Found");

 

 

Да гдело в том что not_found даже вызываться не бугдет (посмотрите первый пост)  :)

Link to comment
Share on other sites

  • 4 years later...

Что то типа того

 

        if ($page < 1 || $page > ceil($product_total / $limit)) {
            $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('information/not_found', $data));
        } else {
            $this->response->setOutput($this->load->view('product/category', $data));
        } 

Link to comment
Share on other sites

  • 1 year later...
В 26.05.2019 в 01:52, zomo сказал:

Что то типа того

 

        if ($page < 1 || $page > ceil($product_total / $limit)) {
            $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('information/not_found', $data));
        } else {
            $this->response->setOutput($this->load->view('product/category', $data));
        } 

почти рилилий вариант. только если зайгдешь в пустую категорию - вылезет ошибка Категория не найгдена

как вариант, можно условие на икое заменить

if ($product_total && ($page < 1 || $page > ceil($product_total / $limit))) {

 

Link to comment
Share on other sites

  • 1 month later...
В 26.05.2019 в 02:52, zomo сказал:

Что то типа того

 

        if ($page < 1 || $page > ceil($product_total / $limit)) {
            $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('information/not_found', $data));
        } else {
            $this->response->setOutput($this->load->view('product/category', $data));
        } 

Извиняюсь, а куда конкретно это добавить ?

Link to comment
Share on other sites


  • 4 months later...

Я добавил редирект с несуещёствующих page=

/catalog/controller/product/category.php

       //301 from not page=
      if ($product_total && ($page < 1 || $page > ceil($product_total / $limit))) {
          header('Location: ' . $this->url->link('product/category', 'path=' . $category_info['category_id'], true), true, 301);
          exit();
      }
      else { }
           //301 from not page=

 

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.