News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How to hide child products (categorized)

Started by goldlink, April 01, 2020, 15:30:40 PM

Previous topic - Next topic

goldlink

Good morning forum, I would have a need.

I would like to hide the child products even if they belong to a category, since being virtuemart connected to a management system, I also receive the data of the belonging categories.

I saw that a change had already been proposed http://forum.virtuemart.net/index.php?topic=103702.0, but the post is very old and it was for the version of Virtuemart 2.

Could anyone help me? Thanks.

Joomla 3.9.16
VirtueMart 3.6.10

Studio 42

The linked fix is poor!
You need to modify the search query, or directly in the product model or better, with a system plugin to load your own productmodel so you dont destroy the virtuemart core files changes on update.

goldlink

Thanks Studio 42, I knew that the link was obsolete, I posted it to start from something that had already been done previously.
I was hoping someone could make the change from that. I believe it is a problem common to many and not just an isolated case.

Thanks anyway for your advice, I will look for some ready solution if you say there are.

Studio 42

No plugin exist, you have to write it.
You can try to find one, but i never here about this.
But a plugin have the advantage to not destroy core files and can be unpublished if you have a problem a day.

PRO


Here is a little function that checks if a product has a parent

function hasParent($pid){
$productModel = VmModel::getModel('product');
$id = $productModel->getProductParentId($pid);
if (!empty($id)){
return 1;
}
}


so in category view
products.php

after this
   foreach ($products as $product ) {

add this

              if(hasChilds($product->virtuemart_product_id)==1) continue;



Oukside

What about creating a category just for the child products and not showing it in the front views / category views?

E.g.
Category:
• Products
• Services
• Child Products

In Products, you have products that are parents of some child products. But when you go on Products category, you see only them and not the child products.