VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sandomatyas on October 26, 2016, 14:41:38 PM

Title: Add custom plugin data to product
Post by: sandomatyas on October 26, 2016, 14:41:38 PM
I want to create a plugin which writes data to the productdetails page or the addtocart area based on the product's data and the plugin's settings without any template override.

E.g. the plugin checks the product price and if the price is under a limit (which is a plugin parameter) writes a link (which is an other parameter), if it's above a limit writes an other text, etc. So I need product data and plugin settings, too.

I can create a customfield plugin but I have to add mannually to the products which isn't a thing what I need. I can do it with template override but the goal is writing a template-independent solution which uses VM customfield postitions to display data.

How should I start whith this?
Title: Re: Add custom plugin data to product
Post by: Milbo on October 26, 2016, 18:39:56 PM
Use a product pattern, create the customfield one time there and the other children have it automatically
Title: Re: Add custom plugin data to product
Post by: sandomatyas on October 27, 2016, 09:34:59 AM
But there are >3000 existing products, multi variants, other parent-child products, etc.
It doesn't sounds good.
Title: Re: Add custom plugin data to product
Post by: Milbo on October 27, 2016, 17:13:12 PM
Why not? you can use one sql to update all products to the new parent product
Read my chapter about caching please https://docs.virtuemart.net/manual/general-concepts/223-caches.html

"It is important to know that VirtueMart has a lot static caching variables to deliver the already produced result directly. Lets say we display a product group, derivated from one parent, then the parent product is loaded only once for all children. "