VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: tangouli on August 20, 2020, 12:22:23 PM

Title: Several Custom fields with type "Related Products"
Post by: tangouli on August 20, 2020, 12:22:23 PM
I use an actual system with joomla 3.9.20 and virtuemart 3.8.4

In virtuemart custom filelds I have created new custum fields with type "related products" with different names and descriptions.

In the virtuemart product there is only one area for "related products".
Where are my new created custom fields with this type to fill in?

Thank you for help.
Title: Re: Several Custom fields with type "Related Products"
Post by: Jörgen on August 20, 2020, 13:56:55 PM
AFAIK there is no possibility to use multiple related products. Why would You do that ?

Jörgen @ Kreativ Fotografi
Title: Re: Several Custom fields with type "Related Products"
Post by: tangouli on August 20, 2020, 14:23:38 PM
Thank you for you answer.

in this special case I want relate several kinds of volants and bordering tapes to an awning fabic.
For both I want relate products with there own title and description.

(By the way: why is it possible to create several custom fields with this type "related products"?)


Title: Re: Several Custom fields with type "Related Products"
Post by: PRO on August 20, 2020, 16:01:59 PM


Can you code at all?

I have a plugin for my site that works just like related products. I use it for "accessories" etc. It basically just displays a product and header.


I could give it to you, but you would have to move some functions around, cause I use my own library to streamline a lot of functions.

Title: Re: Several Custom fields with type "Related Products"
Post by: tangouli on August 20, 2020, 16:10:51 PM
Hel Pro,
that is a very kind offer!
Yes, I am a coder.
I am new to virtuemart but not to php and other shop-systems.
Title: Re: Several Custom fields with type "Related Products"
Post by: Jörgen on August 20, 2020, 17:07:55 PM
Quote from: tangouli on August 20, 2020, 14:23:38 PM
(By the way: why is it possible to create several custom fields with this type "related products"?)

I guess there was an idea to make this generic, but this was not pulled through. It is a free software, You know that right ?

Jörgen
Title: Re: Several Custom fields with type "Related Products"
Post by: StefanSTS on August 20, 2020, 18:37:09 PM
Did you consider making a module position at the place where you want it and place the mod_virtuemart_product module there?

I made a (slider) module in which you can enter the product IDs of the products to show or a category ID.
https://www.jooglies.com/en/virtuemart-extensions/product-slider-light

You can disable the slider JS in the settings and maybe use it like that, or code a bit around inside.
It is basically mod_virtuemart_products with a few additional features. It's from an earlier version of VM so you might want to compare, if the code is still uptodate.

Regards
Stefan
Title: Re: Several Custom fields with type "Related Products"
Post by: PRO on August 20, 2020, 19:21:23 PM
The folder attached.

inside the folder
the zip "product"   is the product plugin you just install.

The folder    "kaizen"   goes into   site/libraries

IF YOU want, you can just take all the functions that are in the library files, and place them into the plugin file product.php
I use a library, cause I use these same functions all across my site, in different plugins and displays.

things to note
if you are not using english  in plugin.php   you will have to change the line to your language.
$product_table=KaizenDatabase::get_table('#__virtuemart_products_en_gb',0);

^^^^ notice   _en_gb   is my language.


I have removed most of the stuff from the library files that does not pertain to this plugin.


You create a custom field, with the position you want.
Then in backend of product, the plugin will create a dropdown list of products you choose (multiple OK)


Then in your product template, you just want to have the position where you want it.


do not private message me, if you need help implementing, reply to this thread
Title: Re: Several Custom fields with type "Related Products"
Post by: tangouli on August 21, 2020, 09:03:41 AM
Thank you all,

PRO fo yout files and StefanSTS for your ideas.
I will try it in the next days and report next week.

@Jörgen: may be, I make that module in future.
(First I need a quick solution while my customer waits ...)
Title: Re: Several Custom fields with type "Related Products"
Post by: tangouli on September 15, 2020, 21:46:39 PM
Thank you Pro for your module!

It does just what I wanted it to do!

It is a very good base for me to develop on it.
I need it multilingual ...

Of course I will report.
Title: Re: Several Custom fields with type "Related Products"
Post by: pinochico on September 16, 2020, 02:31:03 AM
I don't under stand, why I can't duplicate standard VirtueMart Related CustomFileds and setup another position as core Customfileds.

Why I need new plugin for this?

Where is pointer? (maybe my wrong english or google translate :D)
Title: Re: Several Custom fields with type "Related Products"
Post by: pinochico on September 16, 2020, 03:04:19 AM
Ok, I tryied install and setup and maybe I understand what plugin do it and what tangouli want, but I can't chack function - related product is not showed.

Maybe this error?
Warning: mysqli_real_escape_string() expects parameter 2 to be string, object given in /data/www/joomla3.easy.minion.cz/public_html/libraries/joomla/database/driver/mysqli.php on line 251

I setup, add related product from customfield-plugin and add to template:

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_variant','class'=> 'product-related-products','customTitle' => true));

but nothing heapend :(

Title: Re: Several Custom fields with type "Related Products"
Post by: tangouli on September 16, 2020, 13:37:38 PM
Thank you Pro,

I had a problem using the plugin more than once (on different positions with different headings).
It shows then all connected products within all instances of the plugin.

I have corrected it in the plugin, product.php, function plgVmOnDisplayProductFEVM3
by adding the filter-rule:
     foreach ($product->customfields as $field){
     if ((empty($field->product)) ||
         ($group->virtuemart_custom_id != $field->virtuemart_custom_id)) continue;
    ...
you may download the corrected file at
    http://daten.das-web.de/product.zip





Title: Re: Several Custom fields with type "Related Products"
Post by: Studio 42 on September 16, 2020, 14:59:37 PM
I already wrote a plugin that can handel many related products list or list product that can be added to cart
see https://shop.st42.fr/en/products/extra-product.htm
And yes in some shop, this is needed.
For eg a smartphone. You can have related products(memory cards list , phone case list ..... and similar product(other phones) in this case you need 2 lists or more.