Author Topic: Displaying all products under sub-categories too  (Read 95947 times)

voidkun

  • Beginner
  • *
  • Posts: 9
Re: Displaying all products under sub-categories too
« Reply #45 on: March 12, 2011, 00:41:46 am »
this doesnt seem to work in 1.1.6, kept giving me "fatal error, call to unidentified function

nickwalks

  • Beginner
  • *
  • Posts: 14
Re: Displaying all products under sub-categories too
« Reply #46 on: March 29, 2011, 01:37:46 am »
Hello Iashae, Creb, gcrombach, supawat and all other contributors to this thread.

Thanks for all your hard work with this modification. It works really well for me with Joomla 1.5.22 and VM 1.1.5.

Currently this displays all the products - fantastic.

I just have a couple of questions:

1. Does anyone have a solution to display each category with it's title then all the products within that category then a line break or <hr> and the next category and so on. Just to break things up a bit but still group products together.

2. When I am logged in and navigate to "component/virtuemart/?page=shop.registration" it takes me to "products?page=shop.index" which shows the default shop front page which has all the categories as links... Any suggestions here??? If I am not logged in it takes me to the registration page...

Thanks again and any help here would be greatly appreciated.

nickwalks

pelusian

  • Beginner
  • *
  • Posts: 2
Re: Displaying all products under sub-categories too
« Reply #47 on: April 26, 2011, 18:05:44 pm »
Hi all, tnx for your posts, they helped me a lot! I have a problem again: I need to display sub-category name too, so in the same page I'd have
Category name
 subcategory1 name
    subcat1 product1
    subcat1 product2

 subcategory2 name
    subcat2 product1
    subcat2 product2

Tnx in advance for your help

kimmo

  • Beginner
  • *
  • Posts: 10
Re: Displaying all products under sub-categories too
« Reply #48 on: May 23, 2011, 23:12:53 pm »
I try to Creb's code, but i get "fatal error" My Virtuemart is 1.1.5 and Joomla is 1.5.21

I saw that Nickwalks this working very well.

It's harm. I just bought Cherry Picker and want to filter product with that. Now the problem is that filter is lookin attributes from child producst also, and they dont come up in browse page.

I'm kind newbie with code, so any help would be great!

sambo

  • Beginner
  • *
  • Posts: 3
Re: Displaying all products under sub-categories too
« Reply #49 on: July 28, 2011, 06:34:24 am »
@kimmo, check the position of the first code change step and note the extra bracket.

Quote
Posted by: supawat
« on: September 07, 2010, 10:51:31 AM »

    Insert Quote


Thank you Creb. It working great with my Joomla 1.5.20 and VM 1.1.5
This is step by step for do it.
1. EDIT : /administrator/components/com_virtuemart/classes/ps_product_category.php
insert the source code from "Creb"(http://forum.virtuemart.net/index.php?topic=20837.15) between "function sort_alphabetically" and "// Check if there is an extended "
Please beware the "}". It might be make you confusing.
2. EDIT : /administrator/components/com_virtuemart/html/shop_browse_queries.php and follow as Creb's post.

That's it!

potongsaga

  • Beginner
  • *
  • Posts: 6
Re: Displaying all products under sub-categories too
« Reply #50 on: July 29, 2011, 20:25:53 pm »
hi there, im totally new to VM, and totally lost. i took more than a day to figure out how to show cart on the front end of my site...

now after creating categories for my items, i have also created sub categories.

pardon me if this has been posted before, because im really having trouble trying to figure out the thread and solutions..

I have categories such as Dog, Small Animals, Cat. Under each of these category i have Food, Carrier and Cages as subcategories. i managed to add these sub categories into the list on VM. however i realised that when i select the image, "Dog" category on my front end of the VM, i see no items. i understand that i see no items because i do not have any items listed under the category "Dog" but instead listed all my items under the subcategories.

Is there a way where i can click the category image and the various pictures for the subcategories (Food, Carrier, Cages) for that category (Dog) would appear? help! thanks!

webcalida

  • Beginner
  • *
  • Posts: 1
Re: Displaying all products under sub-categories too
« Reply #51 on: July 30, 2011, 01:15:25 am »
Please, someone could help:

My joomla is a 1.5.23 with a Virtuemart 1.1.9

Fatal error: Call to undefined method ps_product_category::untreeCat() in /usr/home/gardenola/www/administrator/components/com_virtuemart/html/shop_browse_queries.php on line 83


Helo again, I change this to VM 1.1.3 and Joomla 1.5.8
In administrator/components/com_virtuemart/classes/ps_product_category.php
add the "untreeCat" function at the end of the class, thanx haselnuss

Code: [Select]
/*
* Returns an array of the categories ids recursively for a given category
* untreeCat copy lashae (virtuemart forum http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=20837.0)
* @param int $kat
* @param int $container
* rewritten by haselnuss (to use ps_DB class and store the function in ps_product_category.php)
*/
function untreeCat($kat, &$container) {
$db = new ps_DB;
$q = "SELECT category_child_id FROM #__{vm}_category_xref WHERE category_parent_id='$kat'";
$db->query($q);
// if it is a leaf (no data underneath it) then return
if (!$db->num_rows()) {
return;
}
//else append the result, and recurse the function (so to speak)
else
{
while($db->next_record()) {
  $container[] = $db->f("category_child_id");
  $kat = $db->f("category_child_id");
  $this->untreeCat($kat, $container);
}
}
}

and in administrator/components/com_virtuemart/html/shop_browse_queries.php I add detect list categories page. I dont know, why can't detect untree function on product details page.
About line 63 change:

Code: [Select]
// Filter Products by Category
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;
}
}

to:

Code: [Select]
// Filter Products by Category
/*
* Returns an array of the categories ids recursively for a given category
* untreeCat copy lashae (virtuemart forum http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=20837.0)
* rewritten by Creb (to use shop.browse page detection)
*/
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 )) {

if ($_GET["page"]=="shop.browse") {
  //$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
$kategoriListesi = array();
$ps_product_category->untreeCat($category_id, $kategoriListesi);
$qkat = " `#__{vm}_product_category_xref`.`category_id` IN(".$category_id . ",";
foreach ($kategoriListesi as $kat)
{
$qkat .= $kat . ',';
}
$qkat .= ")";

$qkat = str_replace(',)', ')', $qkat);
$where_clause[] = $qkat;
} else {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
}

}
}

If we need hide category thumbnails comment line 106 in administrator/components/com_virtuemart/html/shop.browse.php

Code: [Select]
//$navigation_childlist = $tpl->fetch( 'common/categoryChildlist.tpl.php');
Hope this helps someone.

regards
Creb

Kalen

  • Beginner
  • *
  • Posts: 9
Victory!
« Reply #52 on: August 02, 2011, 17:47:52 pm »
Creb!

This works great! ;D

I have a large category structure (>275 categories) with 25,000+ products and a very deep category structure.  On the main VM tree, I can now drill down through all the children/grandchildren and display the complete contents of a category.  The Advance search option, which i have hacked to the main vm Page, now can select a top level category and limit a search to that category and all children/grandchildren!!! This is awsome!  I also have hacked the filter options where the categories are displayed and forced the current selected category to be the default selected option.  This allows the user to immediatly enter search terms and search the products that they are seeing rather than having to select the category that they are presently viewing.  With over 275 categories this is very convenient.  If anyone is interested I can post the mod_virtuemart.php hacks that allow easier searching of the now modified category display structure.  Just let me know.

Thanks again!

relco

  • Beginner
  • *
  • Posts: 5
Re: Displaying all products under sub-categories too
« Reply #53 on: August 13, 2011, 18:30:54 pm »
Any mods for this to work with Virtuemart 1.1.9?

I can display all products from subcategories, but the Category/SubCategory Title will not show..  I need to show each title as a heading so people know under which category the products they see listed are from.

Any help, much appreciated.

Acardenes

  • Beginner
  • *
  • Posts: 29
Re: Displaying all products under sub-categories too
« Reply #54 on: August 25, 2011, 11:01:32 am »
Hi it doesn't work in Joomla Version 1.5.22 with VirtueMart 1.1.8 stable.

I modified it as in Creb's post but all I get in my categories page is a blank page.

Anyone knows a solution for this?

Thanks

funboy

  • Beginner
  • *
  • Posts: 3
Re: Displaying all products under sub-categories too
« Reply #55 on: August 26, 2011, 15:30:58 pm »
Hi all, i'm new here, but i think we will hear us a lot ... virtuemart is realy complicated for me :D

then, I've the same problem using crab code on VM 1.1.8  JOOMLA 1.5.23 ( Blank Screen on category click ) - hompage: http://www.bisped.net 5000 article - up to 6 levels sub category. realy need this function, by this hack or somthing elese.

For help to solve this problem i've attached the shop_browse_queries.php of the VM 1.1.8, can Crab inject the code in the correct way, and re-upload ? becouse i'm not sure of doit in the right way.

Some one with some php knowledge will help us ?

or... I know that a product should be imported in more then one category too, to be shown correctly, but when i import database via CSV i use the 'Category_path'  switch then i cant import the producti in master category also.

some one know here is a query command i can do in phpmyadmin to add to every product all the category in the category path ?

... then, ty and sorry form my english.

[attachment cleanup by admin]

funboy

  • Beginner
  • *
  • Posts: 3
Re: Displaying all products under sub-categories too
« Reply #56 on: September 07, 2011, 08:22:07 am »
after 2 week from my last post, i can say i've tried all the hacks published on internet to add this function without success... in some case my site explode, in some other simpy nothing append. There is really no one can help me with this ? do you think a downgrade to a older virtuemart version copatibile with this hack is the best choice ? or it will create a lot of others problem ...

the virtuemart developer team are working on this function or they think it's unusefull ?

tank you all for the reply ;)

vbkun

  • Beginner
  • *
  • Posts: 21
Re: Displaying all products under sub-categories too
« Reply #57 on: September 08, 2011, 05:15:09 am »
I've got this working on VM 1.1.9 so it should work under 1.1.8 I guess...

I got confess the instructions can be confusing and require a bit of php understand so I'll clearify stuff for funboy:


1) In ps_product_category.php file insert the code from Crab from this page ( http://forum.virtuemart.net/index.php?topic=20837.15 ).
I guess what was confusing was the place. It's right after the function sort_alphabetically ends (in vm 1.1.9 line 1441), but there's something wrapping that function, so, if you look for the function you will see it ends on three }'s, insert it before the last }:

Code: [Select]
function sort_alphabetically( $category_id=0, $level=0 ) {
static $ibg = 0;
.....lots of codes here...
// Traverse the tree down
$this->sort_alphabetically( $db->f('category_child_id'), $level );

$i++;

}
}
Insert Crab's code HERE.
}

2- Edit the shop_browse_queries as Crab described, that part is pretty clear.


funboy

  • Beginner
  • *
  • Posts: 3
Re: Displaying all products under sub-categories too
« Reply #58 on: September 08, 2011, 09:13:23 am »
following your easy step the code work very well ! I guess you are right, in my first ten try there will be something I miss in positioning of this code hack...

I'm very glad to you for your help... i hope a day i can solve you a problem also, meanwhile: TANK YOU.

romero

  • Beginner
  • *
  • Posts: 2
Re: Displaying all products under sub-categories too
« Reply #59 on: September 16, 2011, 14:47:05 pm »
Thank you vbkun  ;D ;D

your post is relay help me because im new in VM and PHP  :P