VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Development & Testing => Topic started by: bcohen0 on August 17, 2017, 22:24:02 PM

Title: Display subcategory products, full depth - VM 3.2.2
Post by: bcohen0 on August 17, 2017, 22:24:02 PM
Here is what I did for my own website to get a full depth display of just products, under a given category. Would this be useful to incorporate in Virtuemart somehow? I hate having mods to a core file.

in administrator/components/com_virtuemart/models/product.php

On or around line 398, where it checks the config value for show_subcat_products, I call my own function in my own class called UserFunctions to do the recursion.

      if ($virtuemart_category_id > 0) {
         $joinCategory = TRUE;
         if(VmConfig::get('show_subcat_products',false)){
            $cats = $virtuemart_category_id;
            UserFunctions::categoryFlatList($cats, $virtuemart_category_id);
            $this->filter_order = "";
            $orderBy="";

            /*GJC add subcat products*/
            /* replaced for full depth search, BC

            $catmodel = VmModel::getModel ('category');
            $childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
            $cats = $virtuemart_category_id;
            foreach($childcats as $childcat){
               $cats .= ','.$childcat->virtuemart_category_id;
               }
            */

            $joinCategory = TRUE;
            $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
         } else {
            $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
         }




Then in Helpers I put my own class UserFunctions:

class UserFunctions {

   /**
    * Contructor
    */
   public function __construct () {

   }



   static public function categoryFlatList(&$cats, $category_id)
   {
      $catmodel  = VmModel::getModel('category');
      $childcats = $catmodel->getChildCategoryList(1, $category_id, null, null, true);
      foreach ($childcats as $childcat)
      {
         $cats .= ',' . $childcat->virtuemart_category_id;
         self::categoryFlatList($cats, $childcat->virtuemart_category_id);
      }
   }


}


Title: Re: Display subcategory products, full depth
Post by: Milbo on August 18, 2017, 10:27:38 AM
Quote from: bcohen0 on August 17, 2017, 22:24:02 PM

         if(VmConfig::get('show_subcat_products',false)){


Thank you for sharing. Seemed to be a lot of work. But when you check the code, you see this config line. It is at the moment a hidden config and enables exactly the behaviour you want, imho. And written with one sql. https://docs.virtuemart.net/manual/general-concepts/206-hidden-configurations.html
Title: Re: Display subcategory products, full depth
Post by: bcohen0 on August 19, 2017, 03:10:04 AM
No, I don't think it does the same thing. Unless the code behind it has changed, it only descends one level I think.  I have a few more levels deep than that.  I had to enable the hidden config in order to get this block of code to execute for my modification, as well. Am I wrong?  If it WILL do this, I'll certainly use it.

I actually didn't think it was alot of work. The essence is changing

  $childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);

to this:

   UserFunctions::categoryFlatList($cats, $virtuemart_category_id);


And making the recursion function.
Title: Re: Display subcategory products, full depth
Post by: Milbo on August 19, 2017, 08:43:04 AM
It is a lot more work, than just setting an hidden config. Furthermore, it is our style to reuse functions and the recursion already exists.

"Unless the code behind it has changed, it only descends one level I think."
Did you test?
Title: Re: Display subcategory products, full depth
Post by: bcohen0 on August 19, 2017, 22:12:08 PM
Yes. You'll notice that I would have had to set that config in order to even get the code I wrote to work. That was the first thing I did, because it did seem obvious that just changing the config would work.  My actual experience was that it only descended to a single level of children. IE; if the category had a category, it would descend into that category and get its children, but if there were deeper levels of categories it didn't descend.

It seems that what you are saying is that this code should have descended full depth- IS that what you are saying?  If so, then I may simply have encountered a condition under which it failed to do so.

Please tell me specifically, if you believe the code that is already here should do full depth, because then I will attempt to reproduce the problem for you. That might be more useful.

Title: Re: Display subcategory products, full depth
Post by: Milbo on August 20, 2017, 00:25:40 AM
Good, nice. We had often people in the forum, directly writing something which already existed. But I wonder that there no function already exists in the category model. We could extend the hidden config.
Title: Re: Display subcategory products, full depth
Post by: bcohen0 on August 20, 2017, 03:46:29 AM
I have re-verified my initial results - on the original code, I get the following list of categories:

17,25,26,27,28,29,43,44

And on the recursive function, I will get the following list of categories:

17,25,26,27,45,46,47,48,49,50,51,52,53,28,29,43,44


The first result is only the first descent level of categories.  The second result is all categories in a depth first search underneath the user-selected category.

I am using VirtueMart 3.2.2

I don't really care if my own method of accomplishing this full depth search is used. I'm certain the virtuemart team can do it better. I'll use whatever the virtuemart team thinks is best, but for my client I needed a full depth return of all products.

Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on August 20, 2017, 08:14:56 AM
ehrm, you should care, because we could add it as hidden option, so you have no problem updating.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on August 24, 2017, 16:14:06 PM
It's true that not all sub category products is displayed using the core code/setting.

T.ex. if you have this structure bellow, it's only products from the first (alphabetically sorted) sub category being displayed in VM 3.2.2:

First category (level one)
- Sub category 1 (level 2)
- Sub category 2 (level 2)
- Sub category 3 (level 2)


PS! Mentioned before here: http://forum.virtuemart.net/index.php?topic=131667.msg466962#msg466962
And also here: http://forum.virtuemart.net/index.php?topic=131667.msg479994#msg479994
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on August 24, 2017, 17:04:55 PM
Rune, this is known, there is an hidden config, which loads the first LEVEL !

Please read again
Quote from: Milbo on August 19, 2017, 08:43:04 AM
"Unless the code behind it has changed, it only descends one level I think."
Did you test?

So we talk about another option "load all children, of all levels"
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on August 24, 2017, 18:12:38 PM
Hm, nice reply.

First level in first sub category only then, it doesn't even load all on first level ...

Anyhow as it is, it doesn't make much sense, when there is other solutions doing what people expect this setting to do, and I don't think they read all the forum to try to find a «hidden» comment about it. So sorry if we don't get the logic in this ...
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on August 24, 2017, 18:35:22 PM
lol, useless, you do not read, you do not listen.

The standard was all the time, that we list only the products of the category, not the also the products of the children categories. And this behaviour is sometimes expected and sometimes not.

So GJC added a new function, which was before just enabled by changing one line in the core. That I added a hidden config show_subcat_products is also listed here as new feature http://virtuemart.net/news/latest-news/479-virtuemart-3-2-cached-and-optimized

and here we talk first time about it http://forum.virtuemart.net/index.php?topic=131667.msg454613#msg454613

It was always handled as function, which loads also the products of the childrenchildren categories. So when it does not, it just means some want
- to load only the products of the selected category
- to load the products of the selected and one level down
- to load the products of the selected and all levels down

or GJC and the others want the also all products. When things seem easy, take more fantasy and you get the real problem ;-)
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on August 24, 2017, 18:48:13 PM
Same can be said about you Max, so thanks for reminding us why people don't bother or care. Don't know why you have to be like that when you don't understand other peoples opinion, or are able to read and understand what is written.

You remember that the setting isn't hidden anymore right?
http://dev.virtuemart.net/projects/virtuemart/repository/entry/branches/com_virtuemart.3.0.12.4/administrator/components/com_virtuemart/models/product.php#L426

And you see what the setting actually says to the user?
- It actually says: "Display all products from all subcategories", so that is what people expect it to do then.

Again, in our tests and on live sites, it ONLY loads products from ONE subcategory (the first), when there is more than one (several first level sub cats). Take a look at the pictures above please. And if this is the behaviour you want to have in VM, consider changing the text on the setting, and also add a help text to it.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on August 24, 2017, 20:17:59 PM
Quote from: Milbo on August 20, 2017, 00:25:40 AM
But I wonder that there no function already exists in the category model. We could extend the hidden config.

You can answer the question yourself. And instead of using the time and implementing it, I am disusssing with you competly nonsense. Because you come here and blame around, instead of constructive work.

While I talk already how to implement it. you do this

Quote from: Rune Rasmussen on August 24, 2017, 16:14:06 PM
It's true that not all sub category products is displayed using the core code/setting.

Why you write this? Did I say that I do not believe bcohen0? So there is no reason to repeat, what he already wrote.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on August 24, 2017, 20:21:47 PM
Yes, you actually did. :)
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on August 24, 2017, 20:27:48 PM
no, I asked for clearification and thanked for the answer.

Quote from: Milbo on August 20, 2017, 00:25:40 AM
Good, nice. We had often people in the forum, directly writing something which already existed. But I wonder that there no function already exists in the category model. We could extend the hidden config.
Title: Re: Display subcategory products, full depth
Post by: Rune Rasmussen on August 24, 2017, 20:52:30 PM
Quote from: Milbo on August 18, 2017, 10:27:38 AM
But when you check the code, you see this config line. It is at the moment a hidden config and enables exactly the behaviour you want, imho.

You didn't read or understand what was written, or/and you didn't look at his code. Else that reply doesn't make any sense.

Quote from: Milbo on August 19, 2017, 08:43:04 AMDid you test?

Here you state that you don't know if it work or not, imho.

Quote from: Milbo on August 20, 2017, 08:14:56 AMehrm, you should care, because we could add it as hidden option, so you have no problem updating.

Here you misunderstood what he wrote. What he tried to tell you is that you can do it your way, if that is better, if only the function is improved to work as the configuration setting implies. He/We only wants it to work as the config text tells us it should work, if you use his solution or comes up with something else is less important.

Quote from: Milbo on August 24, 2017, 20:17:59 PMAnd instead of using the time and implementing it, I am disusssing with you competly nonsense. Because you come here and blame around, instead of constructive work.

First of I didn't see that you intended to do anything about it, only that «we could». Second, I don't see any blaming in this, before you started. Third, so translations isn't constructive work, even if your system wouldn't be so popular without it? Thank you!

Quote from: Milbo on August 24, 2017, 20:17:59 PM
Why you write this? Did I say that I do not believe bcohen0? So there is no reason to repeat, what he already wrote.

To confirm there is a issue, because you once again seemed to not understand it, or care about it. There was no "I understand. You are right, it doesn't work as expected, I will look at it" or similar expected replies.

Sorry for caring! Have a nice evening!

PS! Look at this image I'm adding once more, it's not a hidden config anymore:
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on August 24, 2017, 21:26:07 PM
Anyhow, I also looked at it while having this nice chat ...

And by adding the new function posted by 'bcohen0' to the category model, in bottom of administrator/components/com_virtuemart/models/category.php:
    static public function categoryFlatList(&$cats, $category_id) {
      $catmodel  = VmModel::getModel('category');
      $childcats = $catmodel->getChildCategoryList(1, $category_id, null, null, true);
      foreach ($childcats as $childcat)
      {
         $cats .= ',' . $childcat->virtuemart_category_id;
         self::categoryFlatList($cats, $childcat->virtuemart_category_id);
      }
   }


And then modify the code in the product model (administrator/components/com_virtuemart/models/product.php) to something like:
         if (VmConfig::get('show_subcat_products',false) and !VmConfig::get('show_all_subcat_products',false)){
            /*GJC add subcat products*/
            $catmodel = VmModel::getModel ('category');
            $childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
            $cats = $virtuemart_category_id;
            foreach($childcats as $childcat){
               $cats .= ','.$childcat->virtuemart_category_id;
            }
            $joinCategory = TRUE;
            $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
         } else if (VmConfig::get('show_all_subcat_products',false)) {
            $cats = $virtuemart_category_id;
            VmModel::getModel('category')->categoryFlatList($cats, $virtuemart_category_id);
            $this->filter_order = "";
            $orderBy="";
            $joinCategory = TRUE;
            $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
         } else {
            $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
         }


It could work for those wanting only first sublevel, and those wanting all sublevels.

Sure it should also be added to the visible config, but that should be doable. And sure the code could be better, this is just a quick working proposal based on the existing code and proposal. ;)
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on August 24, 2017, 21:36:18 PM
Quote from: Rune Rasmussen on August 24, 2017, 20:52:30 PM
Quote from: Milbo on August 18, 2017, 10:27:38 AM
But when you check the code, you see this config line. It is at the moment a hidden config and enables exactly the behaviour you want, imho.

You didn't read or understand what was written, or/and you didn't look at his code. Else that reply doesn't make any sense.
simple, I just forgot myself, that I added that 6 months ago. Read the feature list for vm3.2 and you can see how much I implemented. I also explained, why I asked for that, because we had often people who started to code, just because they did not find the option to enable the wanted behaviour.

Quote from: Rune Rasmussen on August 24, 2017, 20:52:30 PM
Quote from: Milbo on August 19, 2017, 08:43:04 AMDid you test?

Here you state that you don't know if it work or not, imho.
LoL. There is enough room for questions. Maybe it worked before that way and the function got broken. or we also had this often, also with skilled members, that they did a wrong test. False positiv, and so on.

Quote from: Rune Rasmussen on August 24, 2017, 20:52:30 PM
Quote from: Milbo on August 20, 2017, 08:14:56 AMehrm, you should care, because we could add it as hidden option, so you have no problem updating.

Here you misunderstood what he wrote. What he tried to tell you is that you can do it your way, if that is better, if only the function is improved to work as the configuration setting implies. He/We only wants it to work as the config text tells us it should work, if you use his solution or comes up with something else is less important.

I understood that. But as mentioned before, a lot people use it that way and I want to ask first if some got used to this behaviour and want it that way. We had this often enough, that we "fix" something and others scream that their misuse of the function got broken. A funny example was preventing "minus costs" for payments, which is used as skonto. So i have to add another option for it.

Furthermore I write the code mainly so I hoped that he got my point with the "Already existing functions in the category model". Hoping that he takes another look, if it can be done with an already existing function.

Quote from: Rune Rasmussen on August 24, 2017, 20:52:30 PM
Quote from: Milbo on August 24, 2017, 20:17:59 PMAnd instead of using the time and implementing it, I am disusssing with you competly nonsense. Because you come here and blame around, instead of constructive work.

First of I didn't see that you intended to do anything about it, only that «we could». Second, I don't see any blaming in this, before you started. Third, so translations isn't constructive work, even if your system wouldn't be so popular without it? Thank you!
I expressed clearly, that it is in his interest, that we take the work. But we had also a release going on and it was delayed for too long time, so I just had no time todo it directly.
I told you, what I felt as blaming. Directly repeating that it does not work, while I am already on solving it.
That you did the translation does not give you the right to jump into a thread and play the troll. (be aware, I said "play" not that you are!)

Quote from: Rune Rasmussen on August 24, 2017, 20:52:30 PM
Quote from: Milbo on August 24, 2017, 20:17:59 PM
Why you write this? Did I say that I do not believe bcohen0? So there is no reason to repeat, what he already wrote.

To confirm there is a issue, because you once again seemed to not understand it, or care about it. There was no "I understand. You are right, it doesn't work as expected, I will look at it" or similar expected replies.

Quote from: Milbo on August 20, 2017, 00:25:40 AM
Good, nice. We had often people in the forum, directly writing something which already existed. But I wonder that there no function already exists in the category model. We could extend the hidden config.
The "Good, nice" was that.

Quote from: Milbo on August 20, 2017, 00:25:40 AM
PS! Look at this image I'm adding once more, it's not a hidden config anymore:
Hehe, yes, thanks for clarification. :-)
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on August 24, 2017, 21:39:11 PM
Quote from: Rune Rasmussen on August 24, 2017, 21:26:07 PM
Anyhow, I also looked at it while having this nice chat ...

.....
Sure it should also be added to the visible config, but that should be doable. And sure the code could be better, this is just a quick working proposal based on the existing code and proposal. ;)

Thank you. Yes, it is almost what I have in mind. I would use the same config value, just as dropdown, because the options exclude each other. And it really looks like, that the function is not already in the category model. I checked that already some hours ago.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on August 24, 2017, 21:55:46 PM
I hardly see how confirming an issue is trolling, but enough about it, thanks for your clarifications on your views. I can live with it.

And yes, I didn't find any existing function to use either. And adding the config as a dropdown sounds like a good idea. Great, thanks.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: el02154 on November 26, 2020, 22:47:05 PM
Sorry for reviving this topic but is there any way to show all children products of all subcategories? I use the option in the backend but I am getting only the first level.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: GJC Web Design on November 26, 2020, 22:58:08 PM
correct -- that is all it is coded for i.e. one level

but this post explains how to return all children from all subcats

http://forum.virtuemart.net/index.php?topic=138193.msg484777#msg484777

add the function

   static public function categoryFlatList(&$cats, $category_id)
   {
      $catmodel  = VmModel::getModel('category');
      $childcats = $catmodel->getChildCategoryList(1, $category_id, null, null, true);
      foreach ($childcats as $childcat)
      {
         $cats .= ',' . $childcat->virtuemart_category_id;
         self::categoryFlatList($cats, $childcat->virtuemart_category_id);
      }
   }


to the category model

and then alter the product model to

if (VmConfig::get('show_subcat_products',false) and !VmConfig::get('show_all_subcat_products',false)){
            /*GJC add subcat products*/
            $catmodel = VmModel::getModel ('category');
            $childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
            $cats = $virtuemart_category_id;
            foreach($childcats as $childcat){
               $cats .= ','.$childcat->virtuemart_category_id;
            }
            $joinCategory = TRUE;
            $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
         } else if (VmConfig::get('show_all_subcat_products',false)) {
            $cats = $virtuemart_category_id;
            VmModel::getModel('category')->categoryFlatList($cats, $virtuemart_category_id);
            $this->filter_order = "";
            $orderBy="";
            $joinCategory = TRUE;
            $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
         } else {
            $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
         }


and add in the congig

show_all_subcat_products=1

this has not been tested by me but the author says it works
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: el02154 on November 27, 2020, 15:05:39 PM
Hello,

thank you for replying. Unfortunately, I tested but still getting only one level childs.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on November 28, 2020, 15:55:11 PM
Quote from: el02154 on November 27, 2020, 15:05:39 PM
Unfortunately, I tested but still getting only one level childs.

What exactly did you test, step by step? I just tested it myself on latest VM, and it still works for me. :)

Note! In administrator/components/com_virtuemart/models/category.php you should add the code before the last }, not exactly at the bottom. Also remember to add the config for it, as mentioned by GJC - in administrator/components/com_virtuemart/virtuemart.cfg
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: el02154 on November 28, 2020, 20:47:01 PM
I test it again with no result,. Check this page:
http://webaholics.gr/ddc2/index.php/el/grafeio-spiti
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Rune Rasmussen on November 29, 2020, 11:01:09 AM
Quote from: Rune Rasmussen on November 28, 2020, 15:55:11 PM
Quote from: el02154 on November 27, 2020, 15:05:39 PM
Unfortunately, I tested but still getting only one level childs.

What exactly did you test, step by step? I just tested it myself on latest VM, and it still works for me. :)

Note! In administrator/components/com_virtuemart/models/category.php you should add the code before the last }, not exactly at the bottom. Also remember to add the config for it, as mentioned by GJC - in administrator/components/com_virtuemart/virtuemart.cfg

It works for sure if done correctly.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: GJC Web Design on November 29, 2020, 11:41:28 AM
test what u get after

VmModel::getModel('category')->categoryFlatList($cats, $virtuemart_category_id);

print 'Debug Line '.__LINE__.' $cats <pre>'; print_r ($cats); print "</pre><br />\n";
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: el02154 on November 29, 2020, 17:18:38 PM
First of all, thanks for helping.

When I put the print commend and leave the php code as is I get nothing.

It seems that this if statement is never executed. Are you sure that the conditions inside if statements on the code provided above are correct?

Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: GJC Web Design on November 29, 2020, 19:03:43 PM
what's the value of your


print 'Debug Line '.__LINE__.' show_all_subcat_products <pre>'; print_r (VmConfig::get('show_all_subcat_products',false)); print "</pre><br />\n";
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: el02154 on November 29, 2020, 20:00:52 PM
Debug Line 461 show_all_subcat_products <pre></pre><br />
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: GJC Web Design on November 30, 2020, 00:19:45 AM
so u haven't set up your config correctly

search on here how to do it

show_all_subcat_products=1
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: el02154 on November 30, 2020, 07:48:29 AM
I have included already this in /administrator/components/com_virtuemart/virtuemart.cfg (check attached).
I should do something more?
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: jenkinhill on November 30, 2020, 11:56:41 AM
Did you then save VM configuration twice to ensure the setting is applied?
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: el02154 on November 30, 2020, 21:13:53 PM
 :) :) :) :) :)

I did right now and all seem ok!!! I did not know I should save twice. Thank you all for helping!
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: jenkinhill on December 01, 2020, 10:35:09 AM
The docs say once = but I like to be sure... http://forum.virtuemart.net/index.php?topic=123137.msg420284#msg420284
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: wadou3a on November 27, 2021, 10:00:14 AM
if anyone needs an updated version for latest virtuemart, I have modified it to work


/administrator/components/com_virtuemart/models/category.php

     static public function categoryFlatList(&$cats, $catId) {
         $catmodel = VmModel::getModel ('category');
      $childcats = $catmodel->getChildCategoryList(1, $catId,null, null, true);
         foreach($childcats as $k=>$childcat){
            if(!empty($childcat->virtuemart_category_id)){
            $cats .= $childcat->virtuemart_category_id .',';
            self::categoryFlatList($cats, $childcat->virtuemart_category_id);
                  }
               }
    }
   

/administrator/components/com_virtuemart/models/product.php

         if(VmConfig::get('show_subcat_products',false)){
            /*GJC add subcat products*/
            $catmodel = VmModel::getModel ('category');
            $cats = '';
            foreach($virtuemart_category_id as $catId){
               $childcats = $catmodel->getChildCategoryList(1, $catId,null, null, true);
               foreach($childcats as $k=>$childcat){
                  if(!empty($childcat->virtuemart_category_id)){
                     $cats .= $childcat->virtuemart_category_id .',';
                  }
               }
               $cats .= $catId;
            }
                if(!empty($cats)){
                    $joinCategory = TRUE;
                    $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
                }
         } else if (VmConfig::get('show_all_subcat_products',false)) {
            $cats = '';
            foreach($virtuemart_category_id as $catId){
               VmModel::getModel('category')->categoryFlatList($cats, $catId);
               $this->filter_order = '';
               $orderBy='';
               $cats .= $catId;
            }
                if(!empty($cats)){
                    $joinCategory = TRUE;
                    $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
                }
         } else {
            $where[] = ' `pc`.`virtuemart_category_id` IN ('.implode(',',$virtuemart_category_id).') ';
         }



Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: infogate on December 20, 2021, 02:16:37 AM
I can confirm that the above code (from wadou3a)  works normally but you have to be sure that the following option in VM Configuration  and shopfront tab is disabled.

Quoteshow products in subcategories = false

I wonder why this code is not still implemented to official release.
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: Milbo on April 30, 2022, 23:04:46 PM
It is imho part of the core. Please try vm4
Title: Re: Display subcategory products, full depth - VM 3.2.2
Post by: razor7 on December 22, 2022, 21:38:54 PM
Quote from: Milbo on April 30, 2022, 23:04:46 PM
It is imho part of the core. Please try vm4

Hi Milbo! I'm using VM 4.0.6 and J 3.10.11 but after enabling show_subcat_products I'm still only getting level 2 category products. IE:

Cat Parent <-- clicked this cat link and
  Cat Child 1 <-- got products from here
  Cat Child 2 <-- got products from here
    Cat Grandchild 1 <-- didn't got products
    Cat Grandchild 2 <-- didn't got products
    Cat Grandchild 3 <-- didn't got products
  Cat Child 3 <-- got products from here

Is this feature implemented in VM?

Thanks!