Hello, is there a way to display all term (empty and ones that have products) in catalog page and block? I have seen a patch for Ubercart 1.3 - but since then nothing seemed to happen and the current version of Ubercart 2.2. still doesn't have such capability. Would you please advice on how to do it.

Thank you.

Comments

sandy-jr’s picture

Anyone please?

sandy-jr’s picture

seemingly a simple issue... but..

sandy-jr’s picture

Anyone please?

Anonymous’s picture

Priority: Normal » Critical

Subscribed.
I have a same problem.

tr’s picture

Component: Code » Catalog
Priority: Critical » Normal
michalczernik’s picture

Subscribing

michalczernik’s picture

Title: displaying empty terms in catalog block » Displaying empty terms in catalog block (Ubercat - show empty categories)

OK, I can't write patches, but I have changed the code below and it did the job.

In the file uc_catalog.module, around line 664 I have changed:

$child->nodes = $n; to
$child->nodes = 1; //DISPLAY EMPTY CATEGORIES PATCH. ORIGINAL: $child->nodes = $n;

and around line 866 I have commented:

  if (!$num) {
    return array(FALSE, '');
  } 

to

  //DISPLAY EMPTY CATEGORIES PATCH. COMMENTED NEXT THREE LINES
 /*
  if (!$num) {
    return array(FALSE, '');
  }
  */

I know this is not a proper clean way how to achieve this, however thought it could be useful to someone...

tr’s picture

Title: Displaying empty terms in catalog block (Ubercat - show empty categories) » Displaying empty terms in catalog block
Version: 6.x-2.2 » 6.x-2.x-dev
andres01’s picture

Displaying empty terms in catalog block SOLVED

Thanks so much loutka

That was exactly the solution I was looking for. Works perfect! I'd say this thread is SOLVED!

particlegirl’s picture

Just thought I'd post that in ubercart 3 (d7) if you just remove if (!$num) { return array(FALSE, ''); }
it works great.

alexp999’s picture

As well as that shown in post #7, you may want to also make the following change to uc_catalog.pages.inc:

      $g_child_nodes = 1; //DISPLAY EMPTY CATEGORIES PATCH. ORIGINAL: $g_child_nodes = 0;
      //foreach ($types as $type) {
      //  $g_child_nodes += taxonomy_term_count_nodes($grandchild->tid, $type);
      //}
tr’s picture

Status: Active » Closed (won't fix)

This behavior won't be changed for Ubercart 6.x-2.x. In Ubercart 7.x-3.x, the catalog is implemented with Views and you can modify the views to do what you want.

alexp999’s picture

This is about the catalog block though, which is not implemented with Views in 7.x-3.x

Its all hardcoded, hence the need for a hardcoded workaround.

longwave’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Closed (won't fix) » Active

If someone who needs this functionality and uses the above hacks can make a patch, it'll be much more likely to be included in Ubercart. We would still need to make this optional somehow, but patches will help greatly.

tr’s picture

For the block, can't you do this using one of the existing taxonomy block modules in Drupal? The Catalog is really meant just to provide basic functionality, because you can't have a store without this functionality. But you can always build the exact behavior you want using other Drupal modules because the Ubercart catalog is just a taxonomy.

As longwave said, it'd be nice to see a patch and preferably test cases to go along with it - that would show there's community interest in this feature. So far we haven't seen that.

philsward’s picture

Update (This isn't a "proper" solution... figured out it doesn't work right after I posted this... keeping it to maybe help someone else figure it out. It should work fine though if you only have 1 level of hierarchy i.e. term -> product, not term -> term -> product) See #18 instead.

If you want to accomplish this is UC3, I "think" I have a solution:

1) Edit the uc_catalog_terms view
2) Add a relationship for: Taxonomy term: Content using Catalog (I renamed the relationship to "catalog")
3) Add the filter: Content: Catalog:delta (Make sure to grab the "taxonomy" version, not the hardcoded UC version)
4) Set the " Operator" to Is Not Empty (NOT NULL)
5) Done! Save it and you should be good.

When testing, MAKE SURE you have an empty category... Don't assume it's empty like I did when playing around and spend 15 minutes trying to get it to work when there's a product sitting there making it "not empty"...

I just got it working so give it a whirl and let us know if it works! If it does work for you, let us know and maybe we can get it added to the documentation for the various common scenarios we all seem to come up with and need help.

philsward’s picture

@TR since the catalog is in views, a lot of the various scenarios can probably be handled with some minor views manipulation. The problem is that views is an absolute beast. I've been using Drupal for 6 years and views for about 5 of those but I still get confused and sometimes don't have a clue as to what the heck I'm doing. My suggestion is to try and get as much documentation how-to's on the various scenarios so you can start pointing people with these questions, over to the documentation. While I'm not specifically pointing at you to create the How-To's, maybe you can point people in that direction to add things when they get a solution working. (Like mine in #16 assuming it actually works)

I think part of this might also be to have someone who DOES know the ins-and-outs of views, to properly setup the scenarios and then document them, but as we all know that's like pulling teeth around here...

An example of something I need help with (I'm not requesting the help here, just saying...) is to have a secondary taxonomy term that shows the products in the catalog that are based off of the non-catalog term. A way of funneling based off the other taxonomy (homeowner vs commercial vs etc.), without having to "expose" anything on the main catalog. (I want to have the main catalog reserved to display everything). I've been playing around with it for a while but still haven't figured it out. There's GOT to be a way to do it with what's available in views, but my limited knowledge in it is keeping me from figuring it out which is the case I'm sure with many others. The absolute best I can come up with is trial and error until something magically works (which is what I had to do to get the solution in #16 to work)

Just my $0.02 on how we can "improve" the catalog.

philsward’s picture

Alright, found another solution that might work (#16 had problems...) The solution does require two extra modules which I don't like but whatever get's the job done, so keep that in mind.

1) Download & Enable jquery_update
2) Download taxonomy_tools
3) Enable Taxonomy Tools & Taxonomy Tools Publisher
4) Go to Site configuration -> Taxonomy Tools -> Taxonomy Publisher and enable the "publish / unpublish" option for the "Catalog" vocabulary. (This will let you publish or unpublish a term, just like you can a node.) You can enable the "automatically publish" option if you want. I have a feeling it will automatically publish a new term, once you create a new node and select the unpublished term. Kind of what you would expect from UC2 functionality. You would have to manually unpublish it though if you take the product out of that term. (I haven't tested it, don't quote me on it)
5) Unpublish the terms you want disabled.
6) Edit the uc_catalog_terms view
7) Add a filter: Taxonomy term: Published and set the operator to Is Empty
8) Save view and test it out.

giupenni’s picture

I not found Content: Catalog:delta