Forums / Templates, Stylesheets, Page Layout / How to make "All products" behave like a category

How to make "All products" behave like a category

Locked

Views: 3,214

Results 1 to 20 of 21
This thread is locked. New replies are disabled.
28 Dec 2007, 3:04 PM
#1
john_rock avatar

john_rock

New Zenner

Join Date:
Dec 2007
Posts:
9
Plugin Contributions:
0

How to make "All products" behave like a category

I've seen this question asked a lot but I haven't found a solution yet.

I added the "Column Layout Grid for Product Listing" upgrade and it's working nicely. However, I then noticed it had no effect on the other product listings (all, new, etc.)

This lead me to search why, and what I've found is that product listings are handled differently from one place to the next, which I don't understand. In my mind, listing all products should look the same as listing products in one category, except you have all you products at the same time. I don't have the PHP skills to change this myself, but hopefully someone has already done this change.

  1. I would like the "All products" link from the categories sidebox to behave like the category listings with "Column Layout Grid for Product Listing".

  2. For a reason I can't explain, the product filter is also different. The add-on uses the alphabetical filter (which I personally don't find useful so I disabled it) instead of the one used in the default "All products" listing, allowing you to order by price, etc. (very useful).

So my wish would be to have all products listing use the "Grid" add-on but with the "Sort by" filter at the top. Has anyone done this or knows how to do this?

Thanks

28 Dec 2007, 6:30 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

This is an example of legacy code. I think the all/featured/new listings are an older method of layout, and when the product listing was redeveloped the others were not brought along too. The listings are scheduled to be regularized and improved in an upcoming version (see the Roadmap).

v1.4 Series
...
5.) Standardize functionality and appearance of the product-listings pages
...

I recently modified my all listing to resemble the regular product listing. It would certainly be doable to rework it for Column Grid, but making it flexible and portable between sites would be a big job.
Using just enough of Column Grid to get the columns, and essentially hard-coding the individual product layout, might be practical for one site.

28 Dec 2007, 7:07 PM
#3
john_rock avatar

john_rock

New Zenner

Join Date:
Dec 2007
Posts:
9
Plugin Contributions:
0

Re: How to make "All products" behave like a category

This would explain the inconsistency from one page to the other. I'm new here so I haven't seen the evolution.

I managed to get a custom filtering drop down in my product listings with the grid add-on thanks to the code posted here: http://www.zen-cart.com/forum/showpost.php?p=397358&postcount=25

The limitation I see for the moment is having to sort on product fields only and they must be displayed. Ideally, you could filter on product popularity or anything else you can think of.

As for having a consistent "all products" listing, I think I'll disable the new and all product listings for now, create an "All products" category and link all my products to this category.

Are you aware of a "structure map" that explains all dependencies of the files making up ZC? I've already made a bunch of mods and I'm afraid all these patches will become a big issue later on.

28 Dec 2007, 7:14 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

I don't believe there is any complete map since there are many hundreds or thousands of files, but there is an organizational chart available in Downloads, and information in the wiki.

Have you made a custom template to hold your changes? That will simplify the task of coordinating with upgrades.

I think your "All products" category is the cleanest way to go for the time being.

28 Dec 2007, 8:02 PM
#5
john_rock avatar

john_rock

New Zenner

Join Date:
Dec 2007
Posts:
9
Plugin Contributions:
0

Re: How to make "All products" behave like a category

Thanks, I'll try to find the chart as this will surely be easier than trying to understand the code and figuring out which files make up a page. (i.e. I still can't find in what page I need to edit to change the style of the grid product listings).

So far I've always copied a file I'm about to edit in my custom template folder, which from what I understand is the way customization should be made.

28 Dec 2007, 10:04 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

Some of the column grid listing layout can be styled in your stylesheet, and some may need to be edited in /includes/modules/your_template/product_listing.php.

Glad to hear you're using the template system correctly.

30 Dec 2007, 2:44 PM
#7
juicevb10 avatar

juicevb10

New Zenner

Join Date:
Nov 2007
Posts:
30
Plugin Contributions:
0

Re: How to make "All products" behave like a category

The All Products category method seems to work fine except that the item count on All Products doubles (because it is counting the linked products as additional products).

Any way around that?

30 Dec 2007, 3:07 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

Turn off the category count? :-)
Do you mean that the item count on the top category doubles? It would be possible to add code to check whether the current category being processed is in a list of cats with all products subs, and divide the count by two before outputting it. Actually, it would be pretty simple code. It would requre manually maintaining the list of cats to do this to.

30 Dec 2007, 3:18 PM
#9
juicevb10 avatar

juicevb10

New Zenner

Join Date:
Nov 2007
Posts:
30
Plugin Contributions:
0

Re: How to make "All products" behave like a category

Hmmm...Thanks again.

Maybe I'll look into recoding, but first I don't know where the option to turn off category count is in the admin.

It would solve my problem to just turn off the category count on just the upper category. I'll have to see the code to see if that is easy, easier, or harder than coding it to ignore links. I'll have to find out where the category count code is.

Manually maintain list of categories how? Sorry I'm not sure what you mean.

30 Dec 2007, 3:21 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to make "All products" behave like a category

juicevb10:

The All Products category method seems to work fine except that the item count on All Products doubles (because it is counting the linked products as additional products).

Any way around that?

If you are showing double counts on your records than your data is not correct in the database ...

If you have 127 Products ... regardless of how many are Linked to multiple categories you will never see more than 127 products unless you have:

1 errors in your database tables

2 errors in your code

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Dec 2007, 3:58 PM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

If one product is linked into two cats, each of those will show that it contains one product. I haven't tested, but would the top cat that holds those cats show two products? Or only one? Apparently two, or else there would not have been a question raised.

The code for the count is in /includes/templates/your_template/sideboxes/tpl_categories.php. Find this```php
if (SHOW_COUNTS == 'true') {
if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
$content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
}
}


      if(in_array($current_path, explode(",",'3,22,21_56'))) { //replace numbers with your cat ids separated by commas
        $content .= CATEGORIES_COUNT_PREFIX . int($box_categories_array[$i]['count']/2) . CATEGORIES_COUNT_SUFFIX;
      } else {
and
}

to get```php
      if (SHOW_COUNTS == 'true') {
        if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
          if(in_array($current_path, explode(",",'3,22,21_56'))) { //replace numbers with your cat ids separated by commas
            $content .= CATEGORIES_COUNT_PREFIX . int($box_categories_array[$i]['count']/2) . CATEGORIES_COUNT_SUFFIX;
          } else {
            $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
          }
        }
      }
30 Dec 2007, 4:10 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to make "All products" behave like a category

Aha! you mean in the Cat box counts not in the All Listing count ...

Yes, in that case it is showing the count of how many products you will find within that Category/tree ... so when you click on a Category you know that there are 10 Products to be found if you follow that branch ...

But the Listings, these are not adding multiple counts based on categories ... and display as single listings going to the master_categories_id ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Dec 2007, 4:10 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

Oops, forgot to add this line which prepares the cPath info:```php
$current_path = str_replace("cPath=","",$box_categories_array[$i]['path']);


This goes above the "if(in_array($current_path,..." line.

You will need to find the cPath of each top cat and include it in the list as shown; that is what I meant by "manually maintaining" the list.


To just turn off category counts (globally is the only option), go to Configuration > My Store.
30 Dec 2007, 8:43 PM
#14
john_rock avatar

john_rock

New Zenner

Join Date:
Dec 2007
Posts:
9
Plugin Contributions:
0

Re: How to make "All products" behave like a category

If you're using a category to simulate an "All products" link instead of the "All product" template that is standard in ZC, you shouldn't have any issues with the count.

If you have two categories with 4 unique items each and "link" (not duplicate) all products to the "all products" new category, you should have 8 products in the count:

Dogs (4)
Cats (4)
All products (8)

However, I haven't tested with sub-categories. Are you using sub-cats?

31 Dec 2007, 4:07 AM
#15
juicevb10 avatar

juicevb10

New Zenner

Join Date:
Nov 2007
Posts:
30
Plugin Contributions:
0

Re: How to make "All products" behave like a category

Ha, apparently my issue has created all sorts of speculation and confusion, so I'll try to provide a bit more information.

I'm running a pretty much new version of 1.3.8 with just the standard template modification, although I'm considering changing some of the core files that affect styles. I've hardly made any changes to the template files except to maybe switch order of display or add/change display code (classes, etc.) That makes it less ikely that I have any errors.

So, back to clearing up what is going on...

  1. Yes, I am using subcategories and it is creating an extra count for each linked item in the upper "All Products" category (used so the listing will display properly in columns).
  2. Here is a link to my store build so you can check it out. The top category is "All Chocolates" not "All Products," so that should help avoid some confusion.

Glen, I looked at your code post fast and it seems like that will work fine as long as I don't have any actual products that are ONLY in the "all products/chocolates" category. Not sure, but I will look at it. Also, thanks for the pointer in the admin config to switch on/off category counts.

Clearly using sub-categories is showing each linked product in addition to each actual product in the upper category, resulting in exactly double count when I link all products to the upper "all whatever' category. It's sort of a hack to make the page display the way I want, so I'm not surprised that something isn't working as planned...ha. I imagine all of this will be fixed when Zen Cart releases a version that is completely css styled!

Hopefully we can figure something out...Thanks!

31 Dec 2007, 4:26 AM
#16
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

Now I see the problem. You really meant it when you said the "all products" cat was showing double the count. You set it up differently than I was advising, and somehow managed to link the products back to the top category which already had subcats. That is an arrangement that is supposed to cause various kinds of strange behavior, and is strictly not kosher.

What I advised was to set up a SUBcategory (at the same level as all the kinds of truffles) and link the individual truffles into that.
So instead of

Categories
All Chocolates (52)

  • Exotic Truffles (20)
  • Classic Truffles (4)
  • Vegan Truffles (2)

you would have

Categories
Truffles (52) <------(which gets cut to 26 by the code I posted above)

  • Exotic Truffles (20)
  • Classic Truffles (4)
  • Vegan Truffles (2)
  • All Truffles (26)

It would be nice to have the individual truffles and the subcats display all at the same time, but the Zen Cart structure does not work the same way as your computer's file manager.

31 Dec 2007, 4:50 PM
#17
john_rock avatar

john_rock

New Zenner

Join Date:
Dec 2007
Posts:
9
Plugin Contributions:
0

Re: How to make "All products" behave like a category

I suggest you do it like so, without using sub-cats, only top cats:

  • Chocolate a
  • Chocolate b
  • Chocolate c
  • All chocolates (all products are linked here and the total count will be equal to the sum of all unique products in your catalog)

FYI, it took a lot of time for the page to load.

31 Dec 2007, 5:04 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to make "All products" behave like a category

Yes, that would be best if there are not going to be more basic types of products... or to get a complete shop overview of the products.
I seem to recall seeing a lot more kinds of chocolates on the site earlier.

31 Dec 2007, 5:06 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to make "All products" behave like a category

You appear to have Products and Categories in the Category ...

Keep in mind ... Categories are designed to hold Categories or Products but not both ...

When you have both Categories and Products in the same Category you will run the risk of issues and pricing issues on searches, pricing, etc.

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Jan 2008, 12:14 AM
#20
juicevb10 avatar

juicevb10

New Zenner

Join Date:
Nov 2007
Posts:
30
Plugin Contributions:
0

Re: How to make "All products" behave like a category

Thanks for the feedback. OK, I'll put them all in a seperate category that doesn't contain both products and categories.

Thanks, John for the tip on the server. I've been having issues with my VPS during certain (late PST) hours. Supposedly the issue will be resolved in January, so now I guess. Anyway, they've offered to refund me for any unusable time I've had.

It makes sense that category pricing might get all messed up with the way I have it now...