Display subcategory products, full depth - VM 3.2.2

Started by bcohen0, August 17, 2017, 22:24:02 PM

Previous topic - Next topic

el02154

Debug Line 461 show_all_subcat_products <pre></pre><br />

GJC Web Design

so u haven't set up your config correctly

search on here how to do it

show_all_subcat_products=1
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

el02154

I have included already this in /administrator/components/com_virtuemart/virtuemart.cfg (check attached).
I should do something more?

jenkinhill

Did you then save VM configuration twice to ensure the setting is applied?
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

el02154

 :) :) :) :) :)

I did right now and all seem ok!!! I did not know I should save twice. Thank you all for helping!

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

wadou3a

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).') ';
         }




infogate

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.

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

razor7

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!
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store