Author Topic: Add extra field in Category?  (Read 308 times)

EvanGR

  • Jr. Member
  • **
  • Posts: 333
Add extra field in Category?
« 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!

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Add extra field in Category?
« Reply #1 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
 

EvanGR

  • Jr. Member
  • **
  • Posts: 333
Re: Add extra field in Category?
« Reply #2 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?

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3165
  • VirtueMart Version: 3.6.11
Re: Add extra field in Category?
« Reply #3 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

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
regards
A

Joomla 3.9.18
php 7.3

pinochico

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 379
    • MiniJoomla
  • VirtueMart Version: 3
Re: Add extra field in Category?
« Reply #4 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?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10404
  • VirtueMart Version: 3+
Re: Add extra field in Category?
« Reply #5 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.




J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)