简体   繁体   中英

Redirecting to main page Opencart

After clicking on the item in the Opencart page, it will again redirect to the main page instead of the product description page. I have also added the manual route of the product page on URL as index.php?route=product/product&product_id=795 but still facing the same problem. I have also found that this page calls again and again till it gives error as "This page isn't working". Please help me with this.

You need to pass one extra variable something like this.

index.php?route=product/product&product_id=795&redirect=home

Now to go to catalog/controller/product/product.php and paste the given below code inside the index method. something like this.

public function index() {
     if (isset($this->request->get['redirect'])) {
            $this->redirect($this->url->link('common/home', '', 'SSL'));
        }

OR if you want to change it dynamically with out custome url.then go to

catalog/controller/product/category.php and find this code.

'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)

And replace with

'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url.'&redirect=home')

And catalog/controller/product/product.php will be as given above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM