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

Acardenes

  • Beginner
  • *
  • Posts: 29
Re: Displaying all products under sub-categories too
« Reply #60 on: September 16, 2011, 15:04:42 pm »
I managed to install this hack with sucess. Do check your code in an IDE and see if you find any missing characters or similar trouble. (That was my case, did a copy inside VIM and missed a char)

Thanks a million!

werkin

  • Beginner
  • *
  • Posts: 20
Re: Displaying all products under sub-categories too
« Reply #61 on: September 30, 2011, 00:46:19 am »
Hi,

Thank you for a great patch! What is the easiest way to insert code to limit the number of items that will show on each category page? We have hundreds of products, so I would like a random, limited number of items displayed (maybe 10).

I tried adding an array_rand() in the function -see below, but it did not work. What would be the correct way to do it?
Code: [Select]
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
{
//added this line - not working!
                        $db = array_rand($db, 10);
     
      while($db->next_record()) {
  $container[] = $db->f("category_child_id");
  $kat = $db->f("category_child_id");
  $this->untreeCat($kat, $container);
}
}
}
}

MODIFIED: I just studied shop_brows_queries.php and see that the functions is really just creating a SELECT statement for the child category ids, is this correct? In light of that, is there any way for me to limit the display to 10 random products (from these categories and sub categories)?


BTW Your Code works great! I did have to look twice at where I placed the code in ps_product_category.php as I did not understand at first that it has to go within the class vm_ps_product_category extends vmAbstractObject { }

Thank You!

kerman

  • Beginner
  • *
  • Posts: 5
Re: Displaying all products under sub-categories too
« Reply #62 on: October 20, 2011, 03:20:43 am »
If you want to limit the number, in global configuration, set the items per page, to 10. I have it to 20, so I've changed it to 10 and works.

edu.caetano

  • Beginner
  • *
  • Posts: 9
Re: Displaying all products under sub-categories too
« Reply #63 on: October 25, 2011, 22:17:02 pm »
Hi people.
This post is very good, it work, but don't is exactly what I want.

In my virtuemart I've it divided like this order:
  • 1. Religious Articles
  • 2. Regional Products
  •       2.1 RegionOne
  •              2.1.1 Magnets of RegionOne
  •              2.1.2 Decorative Plates of RegionOne
  •       2.2 RegionTwo
What I want to do, it's put a link to a new page to show all products of category "2.1 RegionOne" (Magnets, and Decorative Plates). It is possible?

I hope you can help me, I wait for this and I would be very grateful.
Thanks,
   edu.caetano

xtr3m3

  • Beginner
  • *
  • Posts: 1
Re: Displaying all products under sub-categories too
« Reply #64 on: October 25, 2011, 23:57:19 pm »
Hi for all!

Thi is a great code working fine in 1.5.23 and 1.1.6 THX.
But i have a question. In my browse page was sorted the products by latest DESC (product_id). After instering this code modifyed to latest ASC. I modifyd in administrator/components/com_virtuemart/html/product.product_list.php and product.product_list.php but nothing changing.
Now the product.product_list.php :

/** Changed search by date - End */
else {
   $list  = "SELECT * FROM #__{vm}_product WHERE ";
   $count = "SELECT COUNT(*) as num_rows FROM #__{vm}_product WHERE ";
   $q = "product_parent_id='0' ";
   if (!$perm->check("admin")) {
      $q  .= "AND #__{vm}_product.vendor_id = '$ps_vendor_id' ";
   }
   elseif( !empty($vendor) ) {
      $q .=  "AND #__{vm}_product.vendor_id='$vendor' ";
   }
   //$q .= "AND #__{vm}_product.product_id=#__{vm}_product_reviews.product_id ";
   //$q .= "AND #__{vm}_category.category_id=#__{vm}_product_category_xref.category_id ";
   $count .= $q;
   $q .= " ORDER BY product_publish DESC,product_id ";
   //$q .= " ORDER BY product_publish DESC,product_name ";
}
$db->query($count);
$db->next_record();
$num_rows = $db->f("num_rows");

pls help how can sort by latest DESC (The product_id and _sku is same and number increasing) Sorry for my english
THX

luanlun

  • Beginner
  • *
  • Posts: 2
Re: Displaying all products under sub-categories too
« Reply #65 on: December 23, 2011, 04:53:58 am »
Thank for sharing. Great work.
Khách sạn phú quốc
http://longtk.webchuyennghiep.net/khach-san-phu-quoc - Visit for Information about hotel at Phu Quoc Island

carbon-uk

  • Beginner
  • *
  • Posts: 29
Re: Displaying all products under sub-categories too
« Reply #66 on: January 31, 2012, 10:49:18 am »
Got this working, great mod thanks guys,

Anybody know how to put a separator in the results? Preferably the category name.

Thanks again. Works great in 1.1.9

ivannk

  • Beginner
  • *
  • Posts: 10
Re: Displaying all products under sub-categories too
« Reply #67 on: February 10, 2012, 15:05:12 pm »
hello, it is great hack
I have only one problem with hide products. In front page I have hide porducts. How can I solved? 

Alan_Smith

  • Beginner
  • *
  • Posts: 40
Re: Displaying all products under sub-categories too
« Reply #68 on: February 22, 2012, 11:17:47 am »
There are many types products available in one store and it is necessary to define all products by category. Sometimes, main category requires sub-categories to easily find required product. The given code for sub-category is important to add sub-categories option in the website.

pmkdk

  • Beginner
  • *
  • Posts: 3
Re: Displaying all products under sub-categories too
« Reply #69 on: September 07, 2012, 10:18:41 am »
Anyone know how to show category titles with this hack/patch?

Mx150

  • Beginner
  • *
  • Posts: 7
Re: Displaying all products under sub-categories too
« Reply #70 on: October 13, 2015, 18:38:55 pm »
Has someone a solution for Virtuemart 3?

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10743
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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