Post by webs_bd » Tue Jun 05, 2018 6:59 pm

version 3.0.2.0.

For previous versions of Opencart we found extensions or a code snippet to redirect a category or search to a single product result, should a category or search result only contain one product.
Does anyone know of a way to do this in Opencart 3.0.2.0. ?

Thanks

Big Decision
Website Production, Ecommerce & Digital Marketing in the UK
http://www.bigdecision.co.uk


New member

Posts

Joined
Sat Nov 09, 2013 8:29 pm

Post by DigitCart » Tue Jun 05, 2018 8:37 pm

Hi,
In these files:

Code: Select all

catalog\controller\product\search.php
catalog\controller\product\category.php
Find:

Code: Select all

$results = $this->model_catalog_product->getProducts($filter_data);
Add after:

Code: Select all

if(count($results) == 1){
	reset($results);
	$this->response->redirect($this->url->link('product/product', 'product_id=' . key($results), true));
}
Last edited by DigitCart on Wed Jun 06, 2018 1:31 pm, edited 1 time in total.

My Extensions / DigitCart


User avatar
Active Member
Online

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by webs_bd » Wed Jun 06, 2018 5:43 am

Thank you very much.
Will give this a try.

Big Decision
Website Production, Ecommerce & Digital Marketing in the UK
http://www.bigdecision.co.uk


New member

Posts

Joined
Sat Nov 09, 2013 8:29 pm
Who is online

Users browsing this forum: Emanuel.C, supak111 and 25 guests