News:

Looking for documentation? Take a look on our wiki

Main Menu

Extra Related Products

Started by sandomatyas, March 12, 2025, 15:30:33 PM

Previous topic - Next topic

sandomatyas

Hi,

I installed a fresh VirtueMart 4.4.6 and found a custom field type called "Extra Related Products." I have added it, but I can't see how it should work.

My goal is to add grouped related products—for example, when selling smartphones, I would like to add "related cases," "related chargers," "related screen protectors," etc.

Is this field intended for this purpose? If not, what is it used for? Also, what would you suggest for adding grouped related products?

Thanks in advance!

hazael

#1
You have so many forum posts written and you don't know that?  ???

When you publish this custom field, then in the settings of the selected product in the last tab where the custom fields are - above you will find the related products. Enter the SKU code or product name in this field and when it appears, add it.

In order for these related products to be displayed on the front page in the product of your choice, you need to add PHP code in the user interface template

If in productdetails
<?php echo shopFunctionsF::renderVmSubLayout('customfields_related',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true ));?>
If you don't want unnecessary html code, then try to display it like this
<?php foreach ($this->product->customfieldsSorted['related_products'] as $rp); echo $rp->display?>

PS.
In my opinion, this custom field has a flaw - I think it is a bug. Because if I add other related products to the selected product, and in the future they are physically removed from the list of products, then errors start to appear on the site - this should not be the case and this problem has never been fixed.

sandomatyas

Hi,

Hmm, if I understand correctly, you wrote about "related products," but I was asking about "extra related products."



When I assign it, I don't see any changes while typing.




The goal is to have multiple, separate "related products" groups.

I also tried adding a second "Related Products" field, but it doesn't appear in the "custom fields" tab when editing a product.


hazael

#3
Hello, Ok now I understand. From my observations it seems that this addon you are asking about works, but is not supported by the vmadmin template. You would have to look for a bug in the template. All you have to do now is uncheck the [ ] New Admin Template in the settings

You cannot view this attachment.

sandomatyas

Ahh, as I can see, administrator/components/com_virtuemart/assets/js/products.js has support for this input.vmjs-relatedproductsSearch field, but not in administrator/templates/vmadmin/html/com_virtuemart/assets/js/vmuikit_products.js.

As far as I can tell, it could be transferred to the new vmuikit_products.js quite easily. I was able to do it locally. It would be awesome if VM could support this field in the core.  8)

Milbo

Yeh of course it should be supported in the new admin template. I am happy if you provide the fix here. Nasty, that a new template makes so much trouble, hmpf.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

I just copied relatedProductsAutocomplete function and it's init to the new js :)