Skip To Product Detail For One Product Categories

Anyone can throw me a bone here as to what mod I need to make to what script so that if the product category only has one product, instead of showing the one thumbnail just skip to the one product's, product detail page.

Hi, please add:

#file

app/addons/my_changes/controllers/frontend/categories.post.php

#content

/*

*/

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if($mode == ‘view’){

$page = (!empty($_REQUEST['page']))?(int)$_REQUEST['page']:1;
if(empty($_REQUEST['features_hash']) && $page==1){

	//CS-Cart 4.x
	//$products = Registry::get('view')->getTemplateVars('products');

	//CS-Cart 4.3.x
	$products = Tygh::$app['view']->getTemplateVars('products');

	if(count($products)==1){
		reset($products);
		$key = key($products);
		return array(CONTROLLER_STATUS_REDIRECT, 'products.view?product_id=' . $products[$key]['product_id']);
	}
}

}


The custom modification require My Changes add-on to be active, code is working for CS-Cart 4.0.x, 4.1.x, 4.2.x, 4.3.x

I hope that helps,

Valentin
part of hungryweb.net

Works for us.. Thanks for that share....