Classes alist / search: Redirect to product when only 1 in list


when the search or a category listing merely produces 1 result, it would be good to render the resulting product and not list it.

The classes alist and search both have an object “$this->_iAllArtCnt” which could be used to determine that in fact there is only 1 product.

The product data are in the $this->getArticleList() object.

I am looking for help on 2 aspects:

  1. How do I query the getArticleList-object in order to
  2. redirect the page rendering to the details class.

Any help is greatly appreciated!

Hi, try this, should work for alist and search:

class redirectalist extends redirectalist_parent{
    public function render()
		if ($this->_iAllArtCnt==1){
			foreach ($this->getArticleList() as $oArticle){
				$sLoc = str_replace('&','&',$oArticle->getLink());
				header("Location: ".$sLoc, true, 301);
        return $this->getTemplateName();

Thanks so much, Frank - you’re the best!

And that’s another beer for you…

I just changed the response status code to 302, so the category URL remains alive.


The suggested solution works perfectly, and has just one drawback: It adds response time. On my server, this is around 400ms response time for the redirect message, then the 700 to 800 ms for the details page.

Wouldn’t it be nice to resolve this at the level where the framework calculates the category-URL? Since there is already logic for the calculation of the number of member articles, it should be easy to say: if there’s only one product in, my URL is the products URL.

Something to think about…

Cheers, have a good weekend,