Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Redirect to Product Page when only One product in category

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #31  
Old 04-10-2009, 06:42 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Redirect to Product Page when only One product in category

If using a recent version of CDSEO with canonical link support then the primary url would be indexed only regardless.

You could also change the code from:

Code:
{assign var="prodURL" value="product.php?productid=`$products.0.productid`&cat=$cat&page=1"}

to:

Code:
{assign var="prodURL" value="product.php?productid=`$products.0.productid`"}
Reply With Quote
  #32  
Old 06-01-2009, 08:07 AM
 
ChristineP ChristineP is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 310
 

Default Re: Redirect to Product Page when only One product in category

How would I use this code for a category without a subcategory, though there maybe 1 to 5 products?
__________________
______________
version 4.1.9 Gold
Reply With Quote
  #33  
Old 06-01-2009, 09:19 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Redirect to Product Page when only One product in category

Quote:
Originally Posted by ChristineP
How would I use this code for a category without a subcategory, though there maybe 1 to 5 products?

You don't.

The purpose of this mod is so that your customer can simply choose a category (or subcat) and be taken to the ONLY product in the category (or subcat).

There is no other purpose for this mod.

If you have a category with 1 to 5 products, you could make a subcat per product, assign the product as the only product in the subcat, and then use this code.

Got it?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #34  
Old 06-04-2009, 09:43 PM
  AusNetIT's Avatar 
AusNetIT AusNetIT is offline
 

Senior Member
  
Join Date: Apr 2009
Posts: 152
 

Default Re: Redirect to Product Page when only One product in category

HI,

Will this work with 4.2.1?

I want to test. but if anyone done let me know.

Thanks,
__________________
Melbourne website design | SEO in Melbourne

Installed Ver 4.6.0
Reply With Quote
  #35  
Old 10-07-2009, 08:41 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Redirect to Product Page when only One product in category

This DOES NOT work with 4.3 beta3
--- but if you edit this line, it will:
Code:
{assign var="prodURL" value="`$http_location`/`$products.0.page_url`"}
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #36  
Old 11-20-2009, 04:15 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Redirect to Product Page when only One product in category

CONFIRMED to work with 4.3.0 PRO

INSERT the following to the top of /skin1/customer/main/subcategories.tpl

Code:
{* BEGIN MOD to Redirect to Product Page when only One product in category *} {if $products|@count eq 1} {assign var="prodURL" value="`$http_location`/`$products.0.page_url`"} {php} header( "Location: " . $GLOBALS[smarty]->_tpl_vars[prodURL] ); {/php} {/if} {* END MOD to Redirect to Product Page when only One product in category *}
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #37  
Old 11-06-2011, 07:08 AM
  DrQuietus's Avatar 
DrQuietus DrQuietus is offline
 

Advanced Member
  
Join Date: Dec 2005
Posts: 81
 

Default Re: Redirect to Product Page when only One product in category

The above also works with the flyout module in 4.4
Placing it at the top of:
/common_files/modules/Flyout_Menus/Icons/fancy_subcategories.tpl
or
/common_files/modules/Flyout_Menus/Icons/fancy_subcategories_exp.tpl
__________________
Dave Jones
dave@industrialwebworks.net
Mostly 4.7.2 - 4.7.5
Reply With Quote
  #38  
Old 10-10-2012, 07:41 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Redirect to Product Page when only One product in category

Mod confirmed to work with 4.5.3 goldplus!
Not sure if the code needs to change for CDSEO Pro?

INSERT the following to the top of
/skin/common_files/customer/main/subcategories.tpl

Code:
{* BEGIN MOD to Redirect to Product Page when only One product in category *} {if $products|@count eq 1} {assign var="prodURL" value="`$http_location`/`$products.0.page_url`"} {php} header( "Location: " . $GLOBALS[smarty]->_tpl_vars[prodURL] ); {/php} {/if} {* END MOD to Redirect to Product Page when only One product in category *}
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #39  
Old 10-11-2012, 09:51 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Redirect to Product Page when only One product in category

Quote:
Originally Posted by carpeperdiem
Not sure if the code needs to change for CDSEO Pro?

For SEO purposes it would be much better to do the redirect in PHP as this causes a 302 redirect and in PHP you could create a proper 301.
Reply With Quote
  #40  
Old 10-11-2012, 10:10 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Redirect to Product Page when only One product in category

But Jon...

The page doesn't redirect at all - only the category does *to the page). And it redirects to the page, which is indexed. The "category" in this case is NOT indexed, nor do we want it to be, if there is only a single product associated.

Where this technique works well is for a store using flyout menus...

COMPUTER HARDWARE
KEYBOARDS (only 1 item - this takes us directly to product detail page)
MOTHRBOARDS (3 items, this takes us to the category page)
PORTABLE COMPUTERS (2 items, this takes us to the category page)
PRINTERS (3 items, this takes us to the category page)

So although Computer Hardware > Keyboards is a category, this code automatically sends the browsing customer to the one ond only product in the category.

Jon - ARE YOU SUGGESTING that we solve the browsing experience for the customer with a 301? This will mean more work for the admin, since we have to identify each instance of this situation...

Are you also suggesting stores with CDSEO Pro NOT use this technique?

Thanks for the clarification.

J
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:35 AM.

   

 
X-Cart forums © 2001-2020