VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: vanaveno on February 11, 2012, 09:21:41 AM

Title: Display all products under the sub-categories of the current category too VM2
Post by: vanaveno on February 11, 2012, 09:21:41 AM
I need to display all products under the sub-categories of the current category too.
Example: Category tree is:
main-category1 (show all of products)
   -subcategory1 (only products subcategory -1)
   -subcategory2 (only products subcategory -2)
....
Now I get only menu of subcategories I not see products. Is it possible to change this I want to see products not menu subcategory.
I thing there is similar solution of this problem, but it is at VM 1.
http://forum.virtuemart.net/index.php?topic=20837.0
But I need it for VM2. Thanks for respond.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: gamecat2300 on February 13, 2012, 04:15:38 AM
Hi,

I as well would love a solution for this. I was able to get this to work very well with"
http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-navigation/6775

But now that I've moved the site to VM 2 this is no longer an option. Any clues or tips on this?

=-s-=
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: chillmen on May 02, 2012, 11:15:36 AM
Same problem here, if someone could help
Thanks
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: luke67 on May 26, 2012, 16:19:54 PM
Same issue here. Nobody a solution for this?  :-\
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: renevm on May 31, 2012, 11:38:17 AM
I don't have a solution either. Anyone????  :-\
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: mysaq on June 18, 2012, 23:57:30 PM
So... I'm PHP beginner... but... this works for me... :)

After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:


function untreeCat($vm_catid, &$ccont){
   $dbx = JFactory::getDBO();
   $q = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
   $dbx->setQuery($q);
   $dby = $dbx->query();       
   if (!$dby->num_rows) {
      return;
   } else {   
        while($tt = $dby->fetch_row()) {
           array_push($ccont, $tt[0]);
           $kat = $tt[0];
           $this->untreeCat($kat, $ccont);
   }
    }
}


Then search for this:


if ($virtuemart_category_id>0){
    $joinCategory = true ;
    $where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}


... and replace it with following:


if ($virtuemart_category_id>0){
   $joinCategory = true ;
   $catscont = array();
   $this->untreeCat($virtuemart_category_id, $catscont);
   $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
    foreach ($catscont as &$kat){
       $qkat .= ', '.$kat;
    }
    $qkat .= ')';
    $where[] = $qkat;
}


EDIT: There was one missing row in the code here. So I replaced the last part by the Piszi's version. (tested and works)
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Piszi on June 20, 2012, 02:01:23 AM
Actually I think you could make your code more compact if you concat your category id-s, than your query will result only one line or nothing.
So you could do a query like this:
$query = 'SELECT GROUP_CONCAT(`category_child_id` SEPARATOR ", ") FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
This will return something like this: 1, 2, 3, ...

Oh and your $where[] mod has a syntax error
If you put a comma in the query and you doesn't have a child category than you will get a MySQL error because of that comma.
So you should make your code like this:

$catscont = array();
       $this->untreeCat($virtuemart_category_id, $catscont);
       $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
       foreach ($catscont as &$kat){
           $qkat .= ', '.$kat;
       }
       $qkat .= ')';
       $where[] = $qkat;


Otherwise great work!
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: mysaq on June 20, 2012, 02:32:38 AM
I modified the VM1 version only. The syntax error is caused by one missing row in the code here. ( $qkat = str_replace(',)', ')', $qkat); ) Don't know why it diappeared...  ???

I replaced that part of code by your version. Thanks.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: rupesh on June 29, 2012, 17:23:23 PM

Can you please send me product.php

on my site i'm getting
Notice: Trying to get property of non-object in E:\xampp\htdocs\elifeaftercheckout\administrator\components\com_virtuemart\models\product.php on line 172

its not working :'(
Thank you
Rupesh
Quote from: Piszi on June 20, 2012, 02:01:23 AM
Actually I think you could make your code more compact if you concat your category id-s, than your query will result only one line or nothing.
So you could do a query like this:
$query = 'SELECT GROUP_CONCAT(`category_child_id` SEPARATOR ", ") FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
This will return something like this: 1, 2, 3, ...

Oh and your $where[] mod has a syntax error
If you put a comma in the query and you doesn't have a child category than you will get a MySQL error because of that comma.
So you should make your code like this:

$catscont = array();
       $this->untreeCat($virtuemart_category_id, $catscont);
       $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
       foreach ($catscont as &$kat){
           $qkat .= ', '.$kat;
       }
       $qkat .= ')';
       $where[] = $qkat;


Otherwise great work!
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: rupesh on June 29, 2012, 18:30:44 PM
see i uploaded it to live but still it shows subcategory!
http://elifeshopping.com/index.php?option=com_virtuemart&view=category&virtuemart_category_id=1&lang=en
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: perlarenee on July 24, 2012, 20:42:18 PM
i tried this fix as well and could see now change. I'm in vm 2.8 and joomla 2.5.6.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: ThomasR on August 24, 2012, 11:35:46 AM
Still looking for this solution.. Does someone have found a way to get this done?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Robert V. on September 17, 2012, 01:43:52 AM
Quote from: vanaveno on February 11, 2012, 09:21:41 AM
I need to display all products under the sub-categories of the current category too.
Example: Category tree is:
main-category1 (show all of products)
   -subcategory1 (only products subcategory -1)
   -subcategory2 (only products subcategory -2)
....
Now I get only menu of subcategories I not see products. Is it possible to change this I want to see products not menu subcategory.
I thing there is similar solution of this problem, but it is at VM 1.
http://forum.virtuemart.net/index.php?topic=20837.0
But I need it for VM2. Thanks for respond.

Tested this under joomla 2.5.7 with VM 2.0.10.

Within Joomla if you create a menu item that will show every subcategory with the products choose VirtueMart Categories Layout as a link from that menu
for every subcategory make a submenu item that links to every single category layout.


Hence:  main-category1 (show all of the products) - link this one to VirtueMart Categories Layout -> This will display all the products of all categories.
                -subcategory1 (only products subcategory -1) - Link this one to VirtueMart » Category Layout (subcategory 1)
                -subcategory2 (only products subcategory -2) - Link this one to VirtueMart » Category Layout (subcategory 2)

Now depending on the amount of products you'll get a set of pages (default 10 products per page). Just enhance this number to display more products per page.

hope this helped.
                     
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: rupesh on September 22, 2012, 04:14:07 AM
Quote from: Robert V. on September 17, 2012, 01:43:52 AM
Quote from: vanaveno on February 11, 2012, 09:21:41 AM
I need to display all products under the sub-categories of the current category too.
Example: Category tree is:
main-category1 (show all of products)
   -subcategory1 (only products subcategory -1)
   -subcategory2 (only products subcategory -2)
....
Now I get only menu of subcategories I not see products. Is it possible to change this I want to see products not menu subcategory.
I thing there is similar solution of this problem, but it is at VM 1.
http://forum.virtuemart.net/index.php?topic=20837.0
But I need it for VM2. Thanks for respond.

Tested this under joomla 2.5.7 with VM 2.0.10.

Within Joomla if you create a menu item that will show every subcategory with the products choose VirtueMart Categories Layout as a link from that menu
for every subcategory make a submenu item that links to every single category layout.


Hence:  main-category1 (show all of the products) - link this one to VirtueMart Categories Layout -> This will display all the products of all categories.
                -subcategory1 (only products subcategory -1) - Link this one to VirtueMart » Category Layout (subcategory 1)
                -subcategory2 (only products subcategory -2) - Link this one to VirtueMart » Category Layout (subcategory 2)

Now depending on the amount of products you'll get a set of pages (default 10 products per page). Just enhance this number to display more products per page.

hope this helped.
                     

I know this solution! just ping me i will help you!
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Doomas on September 27, 2012, 04:03:42 AM
Quote from: mysaq on June 18, 2012, 23:57:30 PM
So... I'm PHP beginner... but... this works for me... :)

After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:


function untreeCat($vm_catid, &$ccont){
   $dbx = JFactory::getDBO();
   $q = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
   $dbx->setQuery($q);
   $dby = $dbx->query();       
   if (!$dby->num_rows) {
      return;
   } else {   
        while($tt = $dby->fetch_row()) {
           array_push($ccont, $tt[0]);
           $kat = $tt[0];
           $this->untreeCat($kat, $ccont);
   }
    }
}


Then search for this:


if ($virtuemart_category_id>0){
    $joinCategory = true ;
    $where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}


... and replace it with following:


if ($virtuemart_category_id>0){
   $joinCategory = true ;
   $catscont = array();
   $this->untreeCat($virtuemart_category_id, $catscont);
   $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
    foreach ($catscont as &$kat){
       $qkat .= ', '.$kat;
    }
    $qkat .= ')';
    $where[] = $qkat;
}


EDIT: There was one missing row in the code here. So I replaced the last part by the Piszi's version. (tested and works)

Thanks for this solution, i made the following  changes to make this work in Joomla 2.5.7 and Virtumart 2.0.11d. 


function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();

$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}



if ($virtuemart_category_id > 0){
   $joinCategory = TRUE ;
   $catscont = array();
   $this->untreeCat($virtuemart_category_id, $catscont);
   $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
    foreach ($catscont as &$kat){
       $qkat .= ', '.$kat;
    }
    $qkat .= ')';
    $where[] = $qkat;
}


Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: matearts on October 04, 2012, 19:59:20 PM
THANK YOU!! Big help for me! This is worked in Joomla 2.5.7 with VirtueMart 2.

Quote from: Doomas on September 27, 2012, 04:03:42 AM
Quote from: mysaq on June 18, 2012, 23:57:30 PM
So... I'm PHP beginner... but... this works for me... :)

After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:


function untreeCat($vm_catid, &$ccont){
   $dbx = JFactory::getDBO();
   $q = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
   $dbx->setQuery($q);
   $dby = $dbx->query();       
   if (!$dby->num_rows) {
      return;
   } else {   
        while($tt = $dby->fetch_row()) {
           array_push($ccont, $tt[0]);
           $kat = $tt[0];
           $this->untreeCat($kat, $ccont);
   }
    }
}


Then search for this:


if ($virtuemart_category_id>0){
    $joinCategory = true ;
    $where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}


... and replace it with following:


if ($virtuemart_category_id>0){
   $joinCategory = true ;
   $catscont = array();
   $this->untreeCat($virtuemart_category_id, $catscont);
   $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
    foreach ($catscont as &$kat){
       $qkat .= ', '.$kat;
    }
    $qkat .= ')';
    $where[] = $qkat;
}


EDIT: There was one missing row in the code here. So I replaced the last part by the Piszi's version. (tested and works)

Thanks for this solution, i made the following  changes to make this work in Joomla 2.5.7 and Virtumart 2.0.11d. 


function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();

$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}



if ($virtuemart_category_id > 0){
   $joinCategory = TRUE ;
   $catscont = array();
   $this->untreeCat($virtuemart_category_id, $catscont);
   $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
    foreach ($catscont as &$kat){
       $qkat .= ', '.$kat;
    }
    $qkat .= ')';
    $where[] = $qkat;
}

Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: toxedach on October 07, 2012, 10:02:02 AM
great post. And how can I fix this code to show the products not from the child category, and within this category of children categories.
Example directory has http://www.lit-kom.ru/catalog/печи_баные/
there child categories and displayed their findings and their product has child categories.

thank you in advance
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: capricornio on October 18, 2012, 21:40:24 PM
Great post, the modified product.php works fine for me on J2.5.7 and VM2.0.12b.
Only one downside:
When I'm in the browsepage of a Level A category all products from Level B subcategories are displayed just fine, but the select manufacturer box does not give any values of manufacturers from the subcategory products.
Anyone an idea how to hack this ?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: apessoa on November 06, 2012, 20:01:53 PM
Hi

I just saw this thread, maybe you can help me.

I'm setting up a site that has 2 main categories (no products in these) each with subcategories with products. It's a migration from J 1.5 and VM 1.1.19 and I want to keep the underlying logic of categories and "product types"

-) Categories: I want to display the category and subcategories just lik VM does, using the category view. When the user clicks on a subcat, he then sees the corresponding products. This is because we have two main aggregating categories, each with 4+ subcategories and each subcategory with a lot of products.

-) "Product type view": We've moved from product types to custom fields and bought an AJAX filter. So far, so good, when in a subcategory it correctly filters and displays the products according to custom fields. However, I need a view for the products in the subcategories for each of the two main big categories - they are the main aggregators and I want to filter from them.

I followed the steps in this thread and in fact it works, but for the wrong views that I need.
Right now the "category" view displays both subcategories and products from them.

What I need is:

- the "category" view to display just the subcategories when in the main category and the products when in the subcategory - just like the original version.

- And the "categories" view (the one that just displays the subcategories), or some new view, to display the products from subcategories without displaying the category description or its subcategories images.

If anyone can help with some hints....

Thanks in advance and best regards,
Alexandre
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: MarioP on January 03, 2013, 11:00:03 AM
Hello,
I'm working at J2.5.8 and the newest VM2.0.16. I modified the VM according with the posted solution.
QuoteThanks for this solution, i made the following  changes to make this work in Joomla 2.5.7 and Virtumart 2.0.11d.



function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();

$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}





         if ($virtuemart_category_id > 0){
   $joinCategory = TRUE ;
   $catscont = array();
   $this->untreeCat($virtuemart_category_id, $catscont);
   $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
    foreach ($catscont as &$kat){
       $qkat .= ', '.$kat;
    }
    $qkat .= ')';
    $where[] = $qkat;
}

Unfortunately it doesn't work. I'm bad at PHP. I can only state that the code in VM2.0.16 was changed.
Instead of this (Virtumart 2.0.11):
if ($virtuemart_category_id>0){
    $joinCategory = true ;
    $where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}

there is ((Virtumart 2.0.16):

if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}

If someone could help...
Thanks in advance
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: MarioP on January 04, 2013, 09:25:56 AM
I've tried to do something on one's own. I've changed `#__virtuemart_product_categories` in
if ($virtuemart_category_id > 0){
   $joinCategory = TRUE ;
   $catscont = array();
   $this->untreeCat($virtuemart_category_id, $catscont);
   $qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
    foreach ($catscont as &$kat){
       $qkat .= ', '.$kat;
    }
    $qkat .= ')';
    $where[] = $qkat;
}

to  `pc` and it works. Almost works... When it displays product details page, it also displays (at the bottom of the page) all subcategories (images)...
Anybody help?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: MarioP on January 05, 2013, 12:55:25 PM
Everybody who want to reach the same results but without manual PHP code modification, you might see the following page:
http://www.kainhofer.com/virtuemart-2-extensions/vm2-auto-categories-plugin.html (http://www.kainhofer.com/virtuemart-2-extensions/vm2-auto-categories-plugin.html)
Very easy configuration and what is the most important - it works (at least for me...) in Joomla 2.5.8 and Virtumart 2.0.16.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: dharmendrarao on January 09, 2013, 07:43:45 AM
Hi,

I am new to virtuemart. I use virtuemart 1.1.x,

Please help me for showing all products on product detail page.

Example: Category tree is:
main-category1 (show all of products)
   -subcategory1 (only products subcategory -1)
        - product 1
        - product 3
        - product 3
   -subcategory2 (only products subcategory -2)

on "product 1" detail page, i want all other products are listed below to "product 1" of "category1"

Help me please

Thanks
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: jenkinhill on January 09, 2013, 09:55:31 AM
@dharmendrarao VM1.1 is no longer supported.  http://forum.virtuemart.net/index.php?topic=106865.0

There is still a 1.1 section of the forum for those who still have a site with the old versions, so you could try posting there.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: syntalk on March 01, 2013, 13:17:50 PM
Hi All,

This is my first post here and firstly I would like to thank to all who helps on this forum as I found it extremely helpful.

I'm new in Virtuemart and trying to display the products from the category(ies) selected below the category list. I can see the solution presented here is working for some but not for all. My question is has anyone managed to get it working on Joomla! 2.5.8 and Viruemart 2.0.18a?

A bit off-topic question but - is it possible to display subcategories as a list of links (ie. Category1 |  Category2 | Category3 ) no images just text?

I'll appreciate any help.

Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: franci77 on March 15, 2013, 15:56:02 PM
Don't know if topic is obsolete, but here is the working code for the latest version of Virtuemart.

After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:


function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();

$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}


Then search for this:


if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}


... and replace it with following:


if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `pc`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}


Best regards,
franci77
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: MasterDKLB on March 20, 2013, 11:39:48 AM
Thank you franci,

This worked like a charm, i need a little bit change to be exactly what i want.

Is there a way to do the same but instead of talking about subcategory products, i would like to display all products inside each category in the main Categories view.

I try to explain it in a different way, now we display the subcategories product inside the category view. Can i display categories products in the categories view?

Is it possible to do that ? what should i change and in which file then?

Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: master_dk on March 21, 2013, 20:12:17 PM
Okay, at least is there a way to Display the Subcategory name, now i get displayed all the products but i would like to have the subcategory name displayed before its products. For example:

Category 1

  Products of category 1

  Subcategory 1

     Products of subcategory 1

etc.

Anyone have a clue which code i have to change?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: franci77 on March 26, 2013, 14:52:58 PM
Hi MasterDKLB,

I understand what you need, tried to do it, but I couldn't figure it out.
I am quite a beginner in PHP, maybe someone with more experience will hopefully help you out.


Regards,
franci77
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: jhoompk on April 05, 2013, 09:36:59 AM
Thank you franci77 for your help, it works for me like a charm.

Thanks again
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: franci77 on April 08, 2013, 15:29:17 PM
Hi,

Even though this code update actually works, there is a problem that the subcategories products aren't actually assigned to parent categories, and because of that if anyone noticed, you can't filter products by manufacturers.

Besides, the file got overwritten, when you updated VM.

So I found another solution. There is a plugin: http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-categories/23074
The plugin will assign all subcategory's products also to parent categories. So you will have subcategory's products also displayed when you are on parent category view. And now you can also filter them by manufacturers and you don't have to worry about the updates.

Note that product.php should be in default state. And BACKUP your database BEFORE you assign products to parent categories in case you don't like the results.


Best regards,
Franci
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: karuppiah on June 05, 2013, 12:05:13 PM
Great Post matearts ;D
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: liquid.ideas on July 30, 2013, 16:30:09 PM
Thanks Guys, you are all awesome!! Worked like a bomb!! Anyway do you think this could be done as an override?
Perhaps Ivus will know. Thing is there are a couple of places I cant override, like if I put this (above fix) into:

templates/my_template/html/com_virtuemart/models it doesnt do anything, I actually have to put it in the admin folder.

I also have the same problem over writing the featured products if I put the single.php file into:

templates/my_template/html/mod_virtuemart_product/ it wont override either?

I know I went a little off topic here but I would like to override the fix, anyone know where I am going wrong?

Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Maxim Pishnyak on July 30, 2013, 21:21:03 PM
Maybe JHacks extension could automate such tasks (files in models folder etc), how do you think?

As for "mod_virtuemart_product" case:
what are you doing and what is going wrong?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: liquid.ideas on July 31, 2013, 08:46:46 AM
HI Maxim,

To explain, If I create a featured products module, in the drop down parameters you can select which php file to use eg: single, default etc. so to do a template override, I used templates\my_template\html\mod_virtuemart_product\tmpl\singlejofeat.php, but In the module I cannot select the file that I created which is: singlejofeat.php unless I have it in modules/mod_virtuemart_product/singlejofeat.php, not ideal if I update VM, any ideas?

Regards,

Jo
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Maxim Pishnyak on July 31, 2013, 10:24:19 AM
I doubt that VM update will overwrite file like modules/mod_virtuemart_product/singlejofeat.php. Just use for 'singlejofeat.php' file enough unique filename.

Could you have 'singlejofeat.php' in modules/mod_virtuemart_product/singlejofeat.php just for fashion?
Any way instead that file another one tween in templates\my_template\html\mod_virtuemart_product\tmpl\ will be used.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Ninjab on August 10, 2013, 19:55:29 PM
Hi there, I have tried this and it didnt do anything when displaying in category view. My sub categories were exactly the same in its parent category page.

What I am trying to do is this layout:

Category Title
         Sub Category Title
                Product 1    Product 2    Product 3

         Sub Category Title
                Product 1    Product 2    Product 3

Ultimately this would be on the site I am working on as:

Notebook Bags
         
          Ultrabook Bags
                 Product 1    Product 2    Product 3

          Macbook Bags
                 Product 1    Product 2    Product 3

I don't want to display any products from parent category (well I won't have any there anyway :)) and the sub categories need to have their titles and products listed below. I want to display the hierarchy like this page: http://www.incipio.com/cases/iphone-cases/iphone-5-cases.html

I have also attached an image that is how I would like to have it to better explain.

Thanks :)

[attachment cleanup by admin]
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Maxim Pishnyak on August 10, 2013, 21:27:37 PM
Did you have any success with your "Only Sub-categories in Category view" thread?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Ninjab on August 11, 2013, 05:55:31 AM
No one except you had replied unfortunately :(
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Maxim Pishnyak on August 11, 2013, 10:59:49 AM
So what is the current status of your issue?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Ninjab on August 11, 2013, 11:34:47 AM
The current status is my template looks like my attached image now. But I need it to look like the my earlier attached image which is my 2nd attached image here.

The sub categories only list their picture and name. I need only the name (title) of the sub category/s to be listed in the parent category view and their products listed under each sub category title.

All I need is the parent title to be at the top, then the pagnation. Under that to be sub category titles, and under each sub-cat title is their products. As mentioned like in the link from Incipios page.

Thanks.

[attachment cleanup by admin]
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Maxim Pishnyak on August 11, 2013, 11:46:33 AM
To get rid of category images you need to edit template override.

Have you any success with adding products with this:
Quote from: Ninjab on August 10, 2013, 19:26:05 PM
OK thanks I have found it that way via google. I will try altering the code to do that and inspect that thread.
?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Ninjab on August 11, 2013, 11:58:52 AM
getting rid of the parent category image is not the problem, I can do that.

I need this layout:

Category Title (sleeves)
         1st Sub Category Title (iPad)
                Product 1    Product 2    Product 3

         2nd Sub Category Title (iPad mini)
                Product 1    Product 2    Product 3

So far the current layout is the sub categories at the top. And they do not list any products under them.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Ninjab on August 13, 2013, 19:20:29 PM
Surely this is possible? Can someone please help with this?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Mana on September 17, 2013, 09:17:11 AM
Thank you much for this solution, is working like a char  ;).
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: slipperyman on August 13, 2014, 23:05:51 PM
Quote from: Ninjab on August 11, 2013, 11:58:52 AM
getting rid of the parent category image is not the problem, I can do that.

I need this layout:

Category Title (sleeves)
         1st Sub Category Title (iPad)
                Product 1    Product 2    Product 3

         2nd Sub Category Title (iPad mini)
                Product 1    Product 2    Product 3

So far the current layout is the sub categories at the top. And they do not list any products under them.

Did you ever achieved this?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: jenkinhill on December 30, 2014, 11:56:33 AM
Very cryptic. Is that just a statement or is it a question? Same problem as who?  http://forum.virtuemart.net/index.php?topic=79799.0
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: GJC Web Design on January 18, 2015, 22:24:33 PM
If you want help at a bare minimum try to give full information

QuoteDoes this still go for VM3?

Do u think that is a clear question? In this thread apart from totally unhelpful posts like  "that worked - thanks" (what worked?) there are about 3 suggested solutions and ideas

So your questions refer to what exactly?
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: treodude on January 22, 2015, 14:59:17 PM
Hi GJC,

Sorry for wasting your time, the problem is no longer relevant.

I got things messed up after a long day, my fault.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: ablaye90 on April 01, 2015, 07:06:34 AM
Salam
after i do the hack i can't sort by manufacturer
any idea ???
thx
Title: Re: Display all products in sub-categories of the current category VM2 & VM3
Post by: Eireann75 on November 18, 2015, 09:40:22 AM
I just wanted to confirm that this CORE HACK still works in VM 3.0.12 on J! 3.4.5. Also it still is not possible to view manufacturers with this hack – which is only a small let-down in my case.

Why is this solution better than assigning each product to its parent category (there still is a working plugin doing that for you in VM3)? Because of SEO. With this hack you get fewer and more consistent URL to your product.

Quote from: franci77 on March 15, 2013, 15:56:02 PM
Don't know if topic is obsolete, but here is the working code for the latest version of Virtuemart.

After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:


function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();

$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}


Then search for this:


if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}


... and replace it with following:


if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `pc`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}


Best regards,
franci77
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: scotous on December 10, 2015, 13:37:43 PM
Hi,

This cannot be confirmed for VM 3.0.12 on Joom 3.4.5 as the product.php itself has different code:

The old if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}

has now changed to

if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
if(true){
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
} else {
/*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 ($isSite) {
if (!VmConfig::get('show_uncat_parent_products',TRUE)) {
$joinCategory = TRUE;
$where[] = ' ((p.`product_parent_id` = "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` > "0") ';
}
if (!VmConfig::get('show_uncat_child_products',TRUE)) {
$joinCategory = TRUE;
$where[] = ' ((p.`product_parent_id` > "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` = "0") ';
}
}


Eireann75 how did you make it work?

Kind Regards
Theo
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: GJC Web Design on December 10, 2015, 13:59:53 PM
If you searched the forum a bit u would see that this ability is now in the core of 3.0.12

http://forum.virtuemart.net/index.php?topic=131667.msg454613
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: wicko on April 06, 2016, 13:57:41 PM
Not a helpful reply and the link certainly does not lead to an answer.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: Rune Rasmussen on May 30, 2016, 16:20:24 PM
Quote from: scotous on December 10, 2015, 13:37:43 PM
This cannot be confirmed for VM 3.0.12 on Joom 3.4.5 as the product.php itself has different code:

Simply replace the new block of code, and it will work. That solution offered in the new code doesn't load products from all sub categories, so I still prefer the old one.
Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: virtumartuser on July 06, 2016, 09:36:17 AM
Hi,
after "Surely this is possible? Can someone please help with this?" by Ninjab
and  "Thank you much for this solution, is working like a char  ;)." by Mana
but the solution is not given . can you give the solution like :

the above product to show on front end in joomla :
clicking on "+" will show the list of products as  and clicking on (-) will hide .

Category Title (sleeves)
       (-)  1st Sub Category Title (iPad)
               ----- Product 1
               -----Product 2   
              ------Product 3

        (+) 2nd Sub Category Title (iPad mini)
              (  Product 1   
                 Product 2   
                 Product 3) this products will be hidden
on rollover product 1,or 2 or 3 display product information with image and clicking on product will show full content.

Thanks,
               

Title: Re: Display all products under the sub-categories of the current category too VM2
Post by: matevzp2 on September 09, 2016, 14:49:35 PM
Does anyone got an answer ? I have the same problem :/