Author Topic: Display all products under the sub-categories of the current category too VM2  (Read 54298 times)

slipperyman

  • Beginner
  • *
  • Posts: 3
getting rid of the parent category image is not the problem, I can do that.

I need this layout:

Category Title (sleeves)
         1st Sub Category Title (iPad)
                Product 1    Product 2    Product 3

         2nd Sub Category Title (iPad mini)
                Product 1    Product 2    Product 3

So far the current layout is the sub categories at the top. And they do not list any products under them.

Did you ever achieved this?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27431
  • Always on vacation
    • Jenkin Hill Internet
Very cryptic. Is that just a statement or is it a question? Same problem as who?  http://forum.virtuemart.net/index.php?topic=79799.0
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.8 PHP 7.0.33
Testing VM .3.6.0.10075 on Joomla 3.9.8

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8892
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
If you want help at a bare minimum try to give full information

Quote
Does this still go for VM3?

Do u think that is a clear question? In this thread apart from totally unhelpful posts like  "that worked - thanks" (what worked?) there are about 3 suggested solutions and ideas

So your questions refer to what exactly?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

treodude

  • Jr. Member
  • **
  • Posts: 57
Hi GJC,

Sorry for wasting your time, the problem is no longer relevant.

I got things messed up after a long day, my fault.

ablaye90

  • Beginner
  • *
  • Posts: 1
Salam
after i do the hack i can't sort by manufacturer
any idea ???
thx

Eireann75

  • Beginner
  • *
  • Posts: 2
Re: Display all products in sub-categories of the current category VM2 & VM3
« Reply #50 on: November 18, 2015, 09:40:22 am »
I just wanted to confirm that this CORE HACK still works in VM 3.0.12 on J! 3.4.5. Also it still is not possible to view manufacturers with this hack – which is only a small let-down in my case.

Why is this solution better than assigning each product to its parent category (there still is a working plugin doing that for you in VM3)? Because of SEO. With this hack you get fewer and more consistent URL to your product.

Don't know if topic is obsolete, but here is the working code for the latest version of Virtuemart.

After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:

Code: [Select]
function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();

$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}

Then search for this:

Code: [Select]
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}

... and replace it with following:

Code: [Select]
if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `pc`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}

Best regards,
franci77

scotous

  • Beginner
  • *
  • Posts: 43
Hi,

This cannot be confirmed for VM 3.0.12 on Joom 3.4.5 as the product.php itself has different code:

The old
Code: [Select]
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}
has now changed to

Code: [Select]
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
if(true){
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
} else {
/*GJC add subcat products*/
$catmodel = VmModel::getModel ('category');
$childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
$cats = $virtuemart_category_id;
foreach($childcats as $childcat){
$cats .= ','.$childcat->virtuemart_category_id;
}
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
}
} else if ($isSite) {
if (!VmConfig::get('show_uncat_parent_products',TRUE)) {
$joinCategory = TRUE;
$where[] = ' ((p.`product_parent_id` = "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` > "0") ';
}
if (!VmConfig::get('show_uncat_child_products',TRUE)) {
$joinCategory = TRUE;
$where[] = ' ((p.`product_parent_id` > "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` = "0") ';
}
}

Eireann75 how did you make it work?

Kind Regards
Theo

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8892
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
If you searched the forum a bit u would see that this ability is now in the core of 3.0.12

http://forum.virtuemart.net/index.php?topic=131667.msg454613
GJC Web Design
VirtueMart and Joomla Developers - php developers http://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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

wicko

  • Jr. Member
  • **
  • Posts: 72
    • Graphic and web design
Not a helpful reply and the link certainly does not lead to an answer.

Rune Rasmussen

  • Jr. Member
  • **
  • Posts: 161
  • Is the stable release stable?
    • SYNTAX ERROR
  • VirtueMart Version: Latest ;)
This cannot be confirmed for VM 3.0.12 on Joom 3.4.5 as the product.php itself has different code:

Simply replace the new block of code, and it will work. That solution offered in the new code doesn't load products from all sub categories, so I still prefer the old one.
Rune Rasmussen - http://www.syntaxerror.no
Norske nettløsninger og integrasjoner, CONSIGNOR EDI, Mamut ordreimport og produkteksport, kortbetaling og faktura m.m.

Norsk Joomla! - Norwegian Translation Team - http://www.norskjoomla.no

virtumartuser

  • Beginner
  • *
  • Posts: 1
  • A beginner
Hi,
after "Surely this is possible? Can someone please help with this?" by Ninjab
and  "Thank you much for this solution, is working like a char  ;)." by Mana
but the solution is not given . can you give the solution like :

the above product to show on front end in joomla :
clicking on "+" will show the list of products as  and clicking on (-) will hide .

Category Title (sleeves)
       (-)  1st Sub Category Title (iPad)
               ----- Product 1
               -----Product 2   
              ------Product 3

        (+) 2nd Sub Category Title (iPad mini)
              (  Product 1   
                 Product 2   
                 Product 3) this products will be hidden
on rollover product 1,or 2 or 3 display product information with image and clicking on product will show full content.

Thanks,
               


matevzp2

  • Beginner
  • *
  • Posts: 6
  • A beginner
Re: Display all products under the sub-categories of the current category too VM2
« Reply #56 on: September 09, 2016, 14:49:35 pm »
Does anyone got an answer ? I have the same problem :/