VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: EvanGR on April 24, 2020, 11:09:49 AM

Title: Add extra field in Category?
Post by: EvanGR on April 24, 2020, 11:09:49 AM
Hello,

I want to achieve the following (admin):

1) Add a new input field in the product Category page. The admin will be able to type in some data and it will be saved to that category.

2) In the product page, retrieve the data from the field above (from the product's canonical category)

Can somebody outline or describe the steps to achieve this?

Thanks!
Title: Re: Add extra field in Category?
Post by: Studio 42 on April 24, 2020, 12:08:11 PM
HI,
No trigger exist on save category.
The solution can be to create your own system, perhaps using a vmextentend plugin or a system plugin.
In your template override, you have to add a function to get the stored value.
If you need a simple value, you can perhaps use an existing category DB field
 
Title: Re: Add extra field in Category?
Post by: EvanGR on April 24, 2020, 12:11:54 PM
To store the value, can I not just:

1) Create the extra db table column myself (category)
2) Override category edit page to include the extra input field?

Is it more complex than it sounds?
Title: Re: Add extra field in Category?
Post by: AH on April 24, 2020, 12:19:11 PM
Evan

see post #5 same idea for category entity just think categories not product :-)

http://forum.virtuemart.net/index.php?topic=137418.msg481235#msg481235 (http://forum.virtuemart.net/index.php?topic=137418.msg481235#msg481235)

1. Add category table new field
2. update tables/categories to reference your new variable - note this gets overwritten every VM update - so not such a wonderful option
   var $has_medias = null;
   var $mynewfield = '';

3. adjust templates for edit category to get this field
Title: Re: Add extra field in Category?
Post by: pinochico on April 24, 2020, 13:52:25 PM
Pls send info why do you need this customfiled for category?

How will you continue to work with it?
Title: Re: Add extra field in Category?
Post by: PRO on April 25, 2020, 19:44:32 PM
On my site I have many things that are stored outside of vmart, but tied to categories & products.
I have an administrator component that I manage all the info with.
I use "Joomla component creator" https://www.component-creator.com/en/    to make an administrator extension.
Then I add all the fields I want.

For example, I have a "category feature" Table that controls the category page.
Featured product, sub category display, and even assigns custom fields by that category.