VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Products, Prices, Tax and Categories VM 1.1 => Topic started by: Mav3rick on July 03, 2011, 12:23:56 pm

Title: Shows all products from subcategories in parent categories (all branch)
Post by: Mav3rick on July 03, 2011, 12:23:56 pm
Problem with not showing subcategories when you enter to category. I couldn't find any solution on the internet so I coded my solution. Here it go:

---------------------------------------------------------------
file
Code: [Select]
administrator/components/com_virtuemart/html/shop_browse_queries.php
---------------------------------------------------------------

after
Code: [Select]
mm_showMyFileName( __FILE__ ); (about row 20)

insert this code
Code: [Select]
class children_class{
    var $cat_children; // where clause
    var $db_browse; // db controler

    function get_children($parent){
        $q  = "SELECT `category_child_id` FROM `#__{vm}_category_xref` WHERE `category_parent_id`=$parent";
        $this->db_browse->query($q);
        $cat_children_id = array();
    while ($this->db_browse->next_record()){
        array_push($cat_children_id,$this->db_browse->f("category_child_id"));
    }
    foreach($cat_children_id as $cat_child_id){
        $this->cat_children .= " OR `#__{vm}_product_category_xref`.`category_id`=$cat_child_id";
        $this->get_children($cat_child_id);
    }

    return $this->cat_children;
    }
}
---------------------------------------------------------------

after
Code: [Select]
// Filter Products by Category (about row 70)

replace this code
Code: [Select]

if( $category_id ) {
if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
} elseif( empty( $keyword ) && empty( $manufacturer_id )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
}
}
by this
Code: [Select]
if( $category_id ) {
        if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
               $where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
    } elseif( empty( $keyword ) && empty( $manufacturer_id )) {
         $cat_child = "(`#__{vm}_product_category_xref`.`category_id`=".$category_id."";

           // Find Child Category Products
           $children = new children_class;
           $children->db_browse = $db_browse;
           $cat_child .= $children->get_children($category_id);
           $cat_child .= substr($this->cat_children, 0, -3);
           $cat_child .= ")";
           $where_clause[] = $cat_child;
       }
}
---------------------------------------------------------------

After save the file it will shows recursively all products from subcategories and their subcategories  in parent cateogy to the end of the branch.
---------------------------------------------------------------

all edited file
Code: [Select]
http://pastebin.com/iP5nzkud
Sorry for my english  :-[
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: schwanengesang on July 04, 2011, 10:51:09 am
WOW thanks so much! I've been trying to figure out how to show all my products!  ;D ;D ;D cheers  :D
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: iamalive on July 11, 2011, 12:59:03 pm
Thanks a lot! This saved my bacon.

Virtuemart team: Can you build this in? Categories used to be shown and somehow this bit seems to have gone missing in the latest (1.1.9) Version.

Regards

David
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: anaffelici on July 13, 2011, 17:25:49 pm
Perfect!  Thanks a Lot!
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: ann_rk on July 24, 2011, 18:18:48 pm
Is there a way to get it to sort by subcategory name and the add the name above the section?

So for example it shows
Cherry Antique Cabinets
Cherry Antique Base Cabinets
Products of Cherry Antique Base Cabinets
Cherry Antique Wall Cabinets
Products of Cherry Antique Wall Cabinets

Currently I just have one long list of products on the category browse page.
http://www.aaahomedesign.com/index.php?option=com_virtuemart&page=shop.browse&category_id=3&Itemid=6

Any assistance would be greatly appreciated.
Sincerely,
Ann
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: swordandstone on August 01, 2011, 20:38:22 pm
I just registered to thank you... THANK YOU! 8)
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: fonza on August 04, 2011, 10:44:29 am
Hello,
I have question: is posssible to adjust numbers of sub categories in one row?
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: balai on August 04, 2011, 11:11:22 am
Thank you
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: nickbkmediagroup on August 04, 2011, 22:47:59 pm
Is there anyway to show only sub categories and NOT products below? Thanks.
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: Mav3rick on August 08, 2011, 19:21:12 pm
Sorry, I dont know what you mean.. Can you explain it? I think it would be possible, it isnt hard to edit this part of virtuemart.
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: fonza on August 10, 2011, 12:40:39 pm
I think nickbkmediagroup mean that on page is just sub categories whitout all products of this sub categories.
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: Mav3rick on August 11, 2011, 00:31:42 am
Like only links to subcategories or what? Sorry, I really cant imagine what you mean "only subcategories". I would like to help you, bud I cant understand..  :(
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: vmbuilder on August 12, 2011, 10:01:29 am
Thanks Mav3rick - my sub-cat's are displaying now, which is brilliant.

I'd prefer this page to ONLY show the sub-category headings though, and not a list of their products below. Any ideas anyone?

@nickbkmediagroup - any luck with this..?
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: Joomlaapp on August 12, 2011, 11:28:00 am
After looking around for a solution to displaying subcategories in a different way, I think Mav3rick is our only hope to help us out.

Current VM set-up:
(1) Power Tools [Parent Category]
--- 1. Chain Saw
--- (2) Outside Tools [Sub Category]
------ 2. Leaf Blower
--- (2) Inside Tools [Sub Category]
------ 3. Power Drill

These are preset products, parent categories, and subcategories. However, when I attempt to create my own parent category, subcategory, and sub-subcategory, the links don't even show after I click on my own parent category. Instead, I get this category is empty.

Desired VM set-up:
(1) Computer Desks [Parent Category]
--- (2) Wood [Subcategory]
------ (3) Oak [Sub-subcategory]
--------- 1. oak table one [Product]
--------- 2. oak table two [Product]
--------- 3. oak table three [Product]
------ (3) Redwood [Sub-subcategory]
--------- 4. redwood table one [Product]
--------- 5. redwood table two [Product]
--------- 6. redwood table three [Product]
------ (3) ect...
--- (2) Metal [Subcategory]
------ (3) Steel [Sub-subcategory]
--------- 7. steel table one [Product]
--------- 8. steel table two [Product]
------ (3) Titanium [Sub-subcategory]
--------- 9. titanium table one [Product]
--------- 10. titanium table two [Product]
------ (3) ect...

Basically, this desired set-up displays subcategories as links to more subcategories and only the lowest level subcategory displays the actual products.

I'm a day old in the VM scene so I don't know if it's an either/or problem, but I can't seem to have my VM function the way I explained.

Thanks to Mav3rick in advance if you know what I'm hinting at!
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: vmbuilder on August 12, 2011, 11:42:39 am
Getting closer! Tried the following from myopicseer instead (thank you) on http://forum.virtuemart.net/index.php?topic=88352.0

Quote
New to 1.1.9, doesn't display empty categories or subcats.  You must apply an Exclamation point ("not") before the final "empty" to line 86 in admin/components/com_virtuemart/html/shop.browser.php, as such:

elseif( $num_rows == 0 && empty($product_type_id) && !empty($child_list)) {

Now sub-cat headings are displayed without a list of their products underneath - just how I want  :)

But I still need to hide the leftover product column headings (like "image", "price", "descriptions") which are still displaying..?!
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: vmbuilder on August 12, 2011, 12:27:01 pm
Got it! To hide column headings above product listings: http://forum.virtuemart.net/index.php?topic=88352.msg294536#msg294536

Cheers.
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: vmbuilder on August 12, 2011, 12:36:48 pm
Hello,
I have question: is posssible to adjust numbers of sub categories in one row?

Yes it is, edit file:

Code: [Select]
joomla\components\com_virtuemart\themes\default\templates\common\categoryChildlist.tpl.php
Line 8, choose how many you want..!

Code: [Select]
if( !isset( $categories_per_row )) {
$categories_per_row = 3;
}
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: Mav3rick on August 14, 2011, 20:19:21 pm
4 all
if you dont want to show products of subcategories in their parent categories (shows only links to subcategories in menu), simply change file shop_browse_queries.php back to the starting state. But if you want to great functionality of whole virtuemart, every product have to be added to the end of some branch. If someone would be in category which have some children(in the middle of some branch) it cant works great. Try to draw it on the paper... (Of course if you want to shows only links to subcategories, not products of subcategories). If you want to show products too, thats another case, their would be shown twice (with my code editation). I hope I helped you.
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: fonza on August 18, 2011, 18:43:29 pm
Thank you vmbuilder, that help me.
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: agiovacchini on August 20, 2011, 08:38:54 am
Thank you so much Mav3rick, I was just looking for this!
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: relco on August 21, 2011, 22:57:42 pm
I've been looking for an answer for 2 weeks regarding this... Please anyone?

All the products from subcategories are displayed successfully.  Is there a way to display the category/subcategory name title aswell?

At the moment all products appear to be under no category. How can I display each of the category names?
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: voidkun on September 03, 2011, 00:50:10 am
dude youre a legend, got it working fine in VM 1.1.8  :P
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: girkers on September 05, 2011, 13:36:02 pm
I am trying to show the subcategories underneath the parent category (which are empty) however I don't have a html directory as specified in the first post. Where do I find the html directory so that I can implement this.

[edit] I feel like a right idiot, I re-read the original message and found that the html directory is in the /administrator/... folder, this doesn't make sense to me to have a front-end page in the administrator section. Oh well, thanks OP as I now have it working[/edit]

Thanks

Girkers
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: mpfteam on November 14, 2011, 17:26:56 pm
accodring to instructions below it says to go file shop_browse_queries.php in the specified path.... but... i don't have that file. i edited the shop_browse.php and it's not the same...

can you please verify that php file for me?

thank you.



Problem with not showing subcategories when you enter to category. I couldn't find any solution on the internet so I coded my solution. Here it go:

---------------------------------------------------------------
file
Code: [Select]
administrator/components/com_virtuemart/html/shop_browse_queries.php
---------------------------------------------------------------

after
Code: [Select]
mm_showMyFileName( __FILE__ ); (about row 20)

insert this code
Code: [Select]
class children_class{
    var $cat_children; // where clause
    var $db_browse; // db controler

    function get_children($parent){
        $q  = "SELECT `category_child_id` FROM `#__{vm}_category_xref` WHERE `category_parent_id`=$parent";
        $this->db_browse->query($q);
        $cat_children_id = array();
    while ($this->db_browse->next_record()){
        array_push($cat_children_id,$this->db_browse->f("category_child_id"));
    }
    foreach($cat_children_id as $cat_child_id){
        $this->cat_children .= " OR `#__{vm}_product_category_xref`.`category_id`=$cat_child_id";
        $this->get_children($cat_child_id);
    }

    return $this->cat_children;
    }
}
---------------------------------------------------------------

after
Code: [Select]
// Filter Products by Category (about row 70)

replace this code
Code: [Select]

if( $category_id ) {
if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
} elseif( empty( $keyword ) && empty( $manufacturer_id )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
}
}
by this
Code: [Select]
if( $category_id ) {
        if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
               $where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
    } elseif( empty( $keyword ) && empty( $manufacturer_id )) {
         $cat_child = "(`#__{vm}_product_category_xref`.`category_id`=".$category_id."";

           // Find Child Category Products
           $children = new children_class;
           $children->db_browse = $db_browse;
           $cat_child .= $children->get_children($category_id);
           $cat_child .= substr($this->cat_children, 0, -3);
           $cat_child .= ")";
           $where_clause[] = $cat_child;
       }
}
---------------------------------------------------------------

After save the file it will shows recursively all products from subcategories and their subcategories  in parent cateogy to the end of the branch.
---------------------------------------------------------------

all edited file
Code: [Select]
http://pastebin.com/iP5nzkud
Sorry for my english  :-[
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: raffo64 on November 15, 2011, 10:59:43 am
Probably you are using Dreamviewer... try with another browser and you'll find what are you looking for!!"shop_browse_queries.php"
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: nehogymar on December 08, 2011, 17:47:45 pm
Joomla 1.5.22
VM1.1.9

I followed the inrstuction above mentioned, but I've got:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /web/mysite/mysite.com/subdir/administrator/components/com_virtuemart/html/shop_browse_queries.php on line 23

line 23:
Code: [Select]
$DescOrderBy = strtoupper($vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}DescOrderBy", 'DescOrderBy', "ASC" ));
Anybody can help me?
Thanks in advance
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: mkariti on December 13, 2011, 09:19:52 am
Hi there,
Many thanks for the great job!!!
I apply this and it work like a charm! However, for some reason I get the sort by option in the suncategories section. I dont have any products there only subcategories and hence I dont need it to show the sort by. Does anyone know how to take this off?
I dont want to disable it just not to show in the subcategories.
Many thanks
mkariti
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: maszyny on December 13, 2011, 11:31:18 am
Thanks very much :)

I have trouble - i can't remove link from Parent Categories, not subcategories/products. Is it possible to do it?
or though display first product...

sample menu:

xxx  // after click I would like don't show all product only view list product in menu or after click show description first product in window
  yyy
  yyy
  yyy
zzz
  aaa
  bbb
  ccc

Please help me, i am beginer in virtualmarket
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: nehogymar on December 19, 2011, 07:43:45 am
Works, thanks!
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: carbon-uk on January 31, 2012, 11:47:11 am
I've been looking for an answer for 2 weeks regarding this... Please anyone?

All the products from subcategories are displayed successfully.  Is there a way to display the category/subcategory name title aswell?

At the moment all products appear to be under no category. How can I display each of the category names?

Also looking for this??? Anybody?
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: exolut on July 06, 2012, 15:20:40 pm
someone has already made ​​the change for virtuemart 2 ???  :-*
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: Flygye on April 17, 2013, 12:14:01 pm
Thank you so much  Mav3rick.

This does exacly what it  says,  and this peace of code  has solve my problems.
I wanted to do exacly this,  and the developers of virtuemart  doesn't  remember to include this option.

Thanks again.

One question:
This query  show all the products from all the sub-categories, in the main category.
And if i only want to show  the products from the 1st  sub-category?  How can i made that? What i have to change in the code?
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: sorabh on October 21, 2013, 11:46:58 am
PLease tell me the same thing in version 2.0.24. Here i am not able to reach the target file.

Thanks & Regards
Sorabh
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: balai on October 25, 2013, 09:22:02 am
Sorabh there are some dozens of posts about this for VM2
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: Mx150 on October 13, 2015, 18:32:06 pm
Anybody has a solution for this in Virtuemart 3 ?
Title: Re: Shows all products from subcategories in parent categories (all branch)
Post by: GJC Web Design on October 13, 2015, 20:13:18 pm
http://forum.virtuemart.net/index.php?topic=131667.msg454316#msg454316