Post by harleybill » Mon Apr 04, 2011 11:56 pm

Is there a way to skip the category page and go straight to the product page on categories that have only one product.
Last edited by harleybill on Fri Mar 02, 2012 2:11 am, edited 1 time in total.

Harleybill
http://spaparts1.com


User avatar
New member

Posts

Joined
Tue May 04, 2010 7:01 pm


Post by Qphoria » Tue Apr 05, 2011 2:04 am

We will try to add this in future versions. I remember this from zencart and found it useful

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by marc_cole » Tue Apr 05, 2011 8:31 am

Qphoria wrote:We will try to add this in future versions.l
+1

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by jmagro » Thu May 12, 2011 3:32 am

Hiya, any update on this post? I'm using the most recent version but don't see that option. Thanks a bunch!

New member

Posts

Joined
Thu May 12, 2011 3:31 am

Post by sino » Sat Sep 17, 2011 7:12 am

yes this would be very useful, is this still not possible?

Newbie

Posts

Joined
Sat Sep 17, 2011 7:05 am

Post by uksitebuilder » Sat Sep 17, 2011 5:01 pm

the category page would need some extra functions to check if product count = 1

if it does, grab it's id and then redirect to the product

--

same could be done on the search results page, if only 1 result found redirect to it.

I'm updating my search extension soon, so may add this. When I do I'll post the code for it and similar for the category changes too.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by sino » Sun Sep 18, 2011 3:36 am

great, thanks simon, will keep an eye out

Newbie

Posts

Joined
Sat Sep 17, 2011 7:05 am

Post by uksitebuilder » Fri Mar 02, 2012 12:21 am

Sorry for the delay on this guys

edit: catalog/controller/product/category.php

Find:

Code: Select all

			foreach ($results as $result) {
				if ($result['image']) {
Replace with:

Code: Select all

			foreach ($results as $result) {
				if($product_total == 1){
					$this->redirect($this->url->link('product/product', 'product_id='.$result['product_id']));
				}
				
				if ($result['image']) {

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Meshach » Fri May 25, 2012 2:08 am

Thanks man! Great job.

User avatar
Newbie

Posts

Joined
Thu May 24, 2012 5:20 am


Post by Meshach » Mon Jul 16, 2012 2:54 am

-- removed

User avatar
Newbie

Posts

Joined
Thu May 24, 2012 5:20 am


Post by spitos » Wed Nov 07, 2012 7:22 pm

uksitebuilder wrote:Sorry for the delay on this guys

edit: catalog/controller/product/category.php

Find:

Code: Select all

			foreach ($results as $result) {
				if ($result['image']) {
Replace with:

Code: Select all

			foreach ($results as $result) {
				if($product_total == 1){
					$this->redirect($this->url->link('product/product', 'product_id='.$result['product_id']));
				}
				
				if ($result['image']) {
When I applied this and the redirect was used, the breadcrumb trail was lost so I made a change to the redirect line to keep the breadcrumb trail on the product page.

Find:

Code: Select all

			foreach ($results as $result) {
				if ($result['image']) {
Replace with:

Code: Select all

			foreach ($results as $result) {
				if($product_total == 1){
					$this->redirect($this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']));
				}
				
				if ($result['image']) {

Image
Google Analytics Expert - Advanced e-commerce tracking, Product & options reporting, transaction/conversion reporting, Google Adwords conversion & profit reporting, goal & funnel reporting, event tracking, site search tracking, multi-store compatibility, EU Cookie Law compliance and works with any theme or checkout! Easy vqmod install. Get it here


User avatar
Active Member

Posts

Joined
Mon May 23, 2011 6:19 pm
Location - UK

Post by carefree » Thu Nov 22, 2012 1:42 am

I tried this approach and it works really well except I am still missing one thing. I have 10 or less products per main category, so I made a main category, then sub categories that are named the same thing as the product name. Then for each product, I linked it to both the main category and the sub category that it is named after. Then I changed the code on the category.php file as per the instructions above.

The result:
When I go to the main category, I get a description of the category, with all the products listed below in grid form. I also see the main category on the left side bar and below it is a list of all the products (sub categories) that I can click on.

What is wrong:
When I click on a product the categories go back the way they were (only displays the main category, no sub categories).

What I want:
I want the code that will make the subcategories show up on every product page that is within the main category so that no matter what product you are looking at, you can switch to another product within that same category without going back to the first page.

Does this make sense? :)
I need the template name and the code to replace. Seems like it shouldn't be too hard I hope.

Thanks in advance!

Newbie

Posts

Joined
Fri Nov 09, 2012 5:45 am

Post by mlvitor » Thu Dec 20, 2012 12:29 am

Great spitos!
That was a really nice solution! Thanks a lot!

Márcio Vítor
http://www.comunicair.pt
https://facebook.com/ComunicAir


Newbie

Posts

Joined
Thu Dec 06, 2012 6:33 pm

Post by HorseMagic » Sun Jan 20, 2013 6:12 am

I tried this approach and it works really well except I am still missing one thing. I have 10 or less products per main category, so I made a main category, then sub categories that are named the same thing as the product name. Then for each product, I linked it to both the main category and the sub category that it is named after. Then I changed the code on the category.php file as per the instructions above.

The result:
When I go to the main category, I get a description of the category, with all the products listed below in grid form. I also see the main category on the left side bar and below it is a list of all the products (sub categories) that I can click on.

What is wrong:
When I click on a product the categories go back the way they were (only displays the main category, no sub categories).

What I want:
I want the code that will make the subcategories show up on every product page that is within the main category so that no matter what product you are looking at, you can switch to another product within that same category without going back to the first page.

Does this make sense?
I need the template name and the code to replace. Seems like it shouldn't be too hard I hope.

Thanks in advance!

Just wondering if anyone found/knows of a solution for sub categories, it sounds like it is only for categories?

Anita


User avatar
New member

Posts

Joined
Sat Jan 21, 2012 1:55 pm
Location - Australia

Post by gotzon.ibarra » Sat Mar 30, 2013 5:14 am

harleybill wrote:Is there a way to skip the category page and go straight to the product page on categories that have only one product.
My problem was I did not want to use the category view as I have very few products and cd not configure the category.tpl the way I wanted.

This may be an over-simplistic solution, but what I did was:

1) Build a new Banner though with store admin. This allows to add a link for each product e.g. index.php?route=product/product&product_id=52

2) Go to Extensions > Modules and enable 'Carousel' and select the banner just created

3) Eliminate to Menu Bar from header.tpl

Newbie

Posts

Joined
Mon Feb 25, 2013 2:08 am

Post by butte » Sat Mar 30, 2013 11:36 am

One approach is to let a first category (lowest sort, pole position in the race) have no title (fill in some spaces or call it Uncategorized) and put the Product onesies there. Forcing it to load prior to any button click can be omitted or inserted.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by santura » Wed Jun 19, 2013 4:59 pm

I tried to implement the code changes suggested above with vqmod, but the first line of the code to be replaced occurs twice in category.php.

Can anyone tell me how to do this?

New member

Posts

Joined
Fri Jun 14, 2013 8:33 pm

Post by webvet » Wed Jun 19, 2013 7:28 pm

Santura

In your <search> tag for this line use the "index" function:

for example the following code replaces the first instance of the line:

Code: Select all

<search position="replace" index="1"><![CDATA[
if ($result['image']) {
]]></search>
Use index="2" to replace the second instance of the same line.

This is a useful guide to writing code for vQmods http://code.google.com/p/vqmod/wiki/Scripting

Genuine, Honest Opencart Support @ http://webvetservices.com


User avatar
Active Member

Posts

Joined
Thu May 14, 2009 2:04 am
Location - Shropshire, UK

Post by santura » Wed Jun 19, 2013 10:45 pm

Beautiful - Thanks

New member

Posts

Joined
Fri Jun 14, 2013 8:33 pm

Post by j@nnik.dk » Mon Apr 06, 2015 5:58 am

Hallo, I'm looking for a solution like this, but I'm using OC 2.x
Is there a way to add code like this in OC 2.x to get the same function, if only one product i category:

foreach ($results as $result) {
if($product_total == 1){
$this->redirect($this->url->link('product/product', 'product_id='.$result['product_id']));
}

if ($result['image']) {

Please help :-)
Thanks, Jannik

Newbie

Posts

Joined
Mon Apr 06, 2015 5:53 am
Who is online

Users browsing this forum: No registered users and 72 guests