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

aurax

  • Beginner
  • *
  • Posts: 19
Re: Displaying all products under sub-categories too
« Reply #15 on: November 19, 2008, 00:00:54 am »
any patch for 1.1?

i am getting:
Code: [Select]
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/yifahaz1/public_html/shop/administrator/components/com_virtuemart/html/shop_browse_queries.php on line 25

Colosimo

  • Beginner
  • *
  • Posts: 27
    • Grafica Milano
Re: Displaying all products under sub-categories too
« Reply #16 on: February 03, 2009, 22:37:16 pm »
i need the same for VM 1.1.2, that code is not working.
anyone?

c.

Creb

  • Beginner
  • *
  • Posts: 18
Re: Displaying all products under sub-categories too
« Reply #17 on: February 21, 2009, 23:09:35 pm »
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

sizex

  • Beginner
  • *
  • Posts: 7
Re: Displaying all products under sub-categories too
« Reply #18 on: March 10, 2009, 01:14:20 am »
wow thanks so much creb just what I was after.  thats great!

jean-mouloud

  • Beginner
  • *
  • Posts: 1
Re: Displaying all products under sub-categories too
« Reply #19 on: May 25, 2009, 13:31:10 pm »
Thanx a lot Creb!
It was very helpful for me!
Thnx thnx thnx a lot!  :)

CocoDen

  • Beginner
  • *
  • Posts: 5
Re: Displaying all products under sub-categories too
« Reply #20 on: September 22, 2009, 13:33:11 pm »
Hello! I don't understand how I may to make structure on one page (main page):

category1 (title):
- proguct1;
- product2;
- product3;

category2 (title):
- proguct4;
- product5;
- product6;

category3 (title):
- proguct7;
- product8;
- product9...

Which don't need click to link of categories or without categories.
Example: http://artflowers-sib.ru/

Please describe me this more in detail. I'm not professional.

I use Joomla 1.5.10 and VM 1.1.3

CocoDen

  • Beginner
  • *
  • Posts: 5
Re: Displaying all products under sub-categories too
« Reply #21 on: September 23, 2009, 00:38:46 am »
Nobody don't know?

baggiesmad

  • Jr. Member
  • **
  • Posts: 308
Re: Displaying all products under sub-categories too
« Reply #22 on: December 02, 2009, 14:37:55 pm »
Nobody don't know?

did you find a way of sorting this?

afterimage

  • Beginner
  • *
  • Posts: 3
Re: Displaying all products under sub-categories too
« Reply #23 on: June 29, 2010, 16:05:05 pm »
Hi all, I'm getting the following error, any idea what I'm doing wrong?

Code: [Select]
Fatal error: Call to undefined method ps_product_category::untreeCat() in (home directory)/administrator/components/com_virtuemart/html/shop_browse_queries.php  on line 148
I'm using 1.5.18 with 1.1.4

Thanks in advance.

Creb

  • Beginner
  • *
  • Posts: 18
Re: Displaying all products under sub-categories too
« Reply #24 on: June 29, 2010, 20:21:27 pm »
Can You change administrator/components/com_virtuemart/classes/ps_product_category.php ?
You myst add function untreeCat after function sort_alphabetically.
End of teh class vm_ps_product_category.
Work fine for me.
Creb

leonk

  • Beginner
  • *
  • Posts: 9
Re: Displaying all products under sub-categories too
« Reply #25 on: July 21, 2010, 09:38:15 am »
I am using Virtuemart 1.1.4 with Joomla 1.5.18.
What is the code change in administrator/components/com_virtuemart/html/shop_browse.php?
I was unable to find
// Filter Products by Category

Thanks
Leon

Creb

  • Beginner
  • *
  • Posts: 18
Re: Displaying all products under sub-categories too
« Reply #26 on: July 21, 2010, 13:18:07 pm »
sorry, this is my comment :)
You must looking for
Code: [Select]
if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
Creb

leonk

  • Beginner
  • *
  • Posts: 9
Re: Displaying all products under sub-categories too
« Reply #27 on: July 21, 2010, 16:16:07 pm »
Thank you, Creb, I managed to change and add the codes in the 2 files

But the shop does not show what I expect to see:
Example:
Categorie A
Sub-categorie A1  2 articles
Sub-categorie A2  3 articles
Sub-categorie A3  5 articles

When I choose Categorie A in the tree I would like to see 10 articles (sorted in Sub-categories) and I see only the links with Sub-categorie A1, Sub-categorie A2 and Sub-categorie A2 and no articles.
When I choose a Sub-categorie in the tree, e.g. A3 I see the correct (5) articles.

How do I proceed?
Thanks
Leon

Creb

  • Beginner
  • *
  • Posts: 18
Re: Displaying all products under sub-categories too
« Reply #28 on: July 21, 2010, 16:56:43 pm »
you have link to shop?
Creb

leonk

  • Beginner
  • *
  • Posts: 9
Re: Displaying all products under sub-categories too
« Reply #29 on: July 21, 2010, 17:17:53 pm »
Think I managed it by through a walkaround: I linked a product to both a category and a sub-category