Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to have different product listings on each category


Lussay

Recommended Posts

Posted

Hi there!

 

I have been using Oscommerce for about 5 months now and customized it for a site. Thanks to this wonderfull site I have found almost everything i needed in order for it to be customized properly. However I did not find one thing and also saw that there are other people that are searching for something like this for quite some time.

 

This thing is how to have different product listings on different categories. For example if you may have a category in which you would like to have the default listing from oscommerce. I find this usefull for product lists don't have pictures. However on a page that you have products with pictures you may want to have a product listing like the ones of the new products one. Or any other product listing that you may find in the contribution section.

 

I will not make this a contribution since I don't know how but if anyone else has the time and wants to customize the code for it to have an admin panel or something please be my guest.

 

Now let's go to the code part.

 

First of all prepare yourself the different product listings that you want to put in your site and put them in /includes/modules and give them a number like product_listing.php, product_listing2.php etc.

 

Second of all go to your filenames.php file in includes and for each product listing that you have add

 

define('FILENAME_PRODUCT_LISTING', 'product_listing.php');
define('FILENAME_PRODUCT_LISTING2', 'product_listing2.php');

 

on the last row right before the last ?> tag.

 

Last thing go to index.php and find the row that says :

 

<td>include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);} ?></td>

 

and replace it with:

 

<td><?php if ($cPath_array[0]==[b]XXX[/b]){		
	include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING2);}
	else{ 
	include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);} ?></td>

 

 

Now instead of XXX you will have to put the cpath id of the parent cattegory that you want the first product_listing2.php to be used. For the rest of the cattegories the default product listing will be used. In order to get the cpath id you can either check your database or you can look into the browser and notice that when you open a new category it says cpath=XXX.

 

You can also use more ifs or a switch if you want more product listings. It's all up to you.

 

Hope this helps someone.

  • 1 month later...
Posted

Hi Lussay,

 

This post is perfect for me i think. I have searched everywhere for an answer.

 

Here is my problem, i have 3 categories


  •  
  • Towbars
  • Trailers
  • Accessories

 

I want to be able to show a differnt product listing for each category, for example


  •  
  • Towbars table headings want to be:- part#, product name, year etc
  • Trailers headings want to be:- model, length, width, height etc
  • Accessories headings want to be:- product, description etc

 

I have changed the index.php page like you said and now it looks at

-------------

<?php if ($cPath_array[0]==22){

include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING2);}

if ($cPath_array[0]==21){

include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);}

if ($cPath_array[0]==34){

include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING3);}

?>

-------------

 

And created the product listing 2 and 3. so now each category is looking at each of the 3 files.

But when i edit the product listing 2 and 3 pages i keep getting errors. for example on the trailers page i have removed the fields i didnt want, but it always wants to always display 10 columns

 

Here are the links so u can see what i mean:-

 

towbars ------ http://www.psb-towing.com/shop/index.php?cPath=21_25_32_30

trailers ----- http://www.psb-towing.com/shop/index.php?cPath=22_26

accessories -- http://www.psb-towing.com/shop/index.php?cPath=34

 

any ideas of how to solve this problem?

 

also is there any possibilty of making seperate tables in the database for the products in each category?

and when inserting the new product from admin it only shows the input fields correct for the spefic category im in.

 

Hope this made sense, am desperate for help.

 

Thanks in advance

Matthew

Posted

forgot to say im using sts and oscommerce-2.2rc2a.

 

Dont know if this makes any difference

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...