Author Topic: Product Count , Categories with One Product and Random Category Images mods  (Read 3015 times)

Steve

  • Beginner
  • *
  • Posts: 31
Here's hack for the products_in_category function in ps_product_category.php

It will also count all products in sub categories.

Code: [Select]

        function products_in_category( $category_id ) {
                if( PSHOP_SHOW_PRODUCTS_IN_CATEGORY == '1' ) {

                        $category_a = array($category_id);
                        $db2 = new ps_DB;
                        while(list($key,$val) = each($category_a)) {
                                $q2 = "SELECT category_child_id FROM #__{vm}_category_xref,jos_vm_category";
                                $q2 .= " WHERE #__{vm}_category_xref.category_parent_id=$val";
                                $q2 .= " AND category_id=category_child_id AND category_publish='Y'";
                                $db2->setQuery($q2);
                                $db2->query();
                                while ($db2->next_record()) {
                                   array_push($category_a,$db2->f("category_child_id"));
                                }
                        }
                        $product_a = array();
                        foreach($category_a as $val) {
                                $q2 = "SELECT #__{vm}_product_category_xref.product_id as products";
                                $q2 .= " FROM #__{vm}_product, jos_vm_product_category_xref";
                                $q2 .= " WHERE #__{vm}_product_category_xref.category_id=$val";
                                $q2 .= " AND #__{vm}_product.product_id=#__{vm}_product_category_xref.product_id";
                                $q2 .= " AND #__{vm}_product.product_publish='Y'";
                                $db2->setQuery($q2);
                                $db2->query();
                                        while ($db2->next_record()) {
                                                array_push($product_a,$db2->f("products"));
                                        }
                        }
                        $num = count($product_a);
                        return " ($num) ";

                }

                else
                return ( "" );
        }



Here a link to a mod I posted in another topic.
http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=28535.msg81413#msg81413

It hides a category that only has one product and no sub categories from the browse page and will list the product information when viewing the products parent category.


Here's the link to the last...
http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=28610.msg81315#msg81315

It will get a list of all the products under the current category being viewed, including all sub categories. Then it will randomly select an image to use as the Category image for that category.