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));
}
Please do not edit the core files, Use ocmod or vqmod instead.
Last edited by DigitCart on Tue Oct 06, 2020 4:31 am, edited 2 times in total.

My Extensions


User avatar
Active Member

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

Post by doogy2223 » Tue Feb 18, 2020 11:55 pm

Has anyone had any luck with this.. I need this function but it is not working for me.

Newbie

Posts

Joined
Mon Jul 16, 2012 11:01 pm

Post by cyclops12 » Wed Feb 19, 2020 3:01 am

doogy2223 wrote:
Tue Feb 18, 2020 11:55 pm
Has anyone had any luck with this.. I need this function but it is not working for me.
Well the code posted by digitcart above works on default 3.0.2.0

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by M1ch831Gr8nt » Fri Jan 12, 2024 2:11 am

Do you have a solution for opencart v4.0.2.3?

Newbie

Posts

Joined
Wed Jul 17, 2013 11:33 pm

Post by AquaJeth5517 » Tue Jan 23, 2024 2:01 pm

Did you have a fix for this issue? Skyward FBISD

Newbie

Posts

Joined
Tue Jan 23, 2024 1:58 pm

Post by paulfeakins » Tue Jan 23, 2024 10:38 pm

If anyone is still looking for a solution and can't find an extension, you could pay a developer such as ourselves or post a job in the Commercial Support Forum.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 86 guests