Author Topic: Adding new fields to product + changing SQL queries to retrieve a product  (Read 266 times)


  • Jr. Member
  • **
  • Posts: 81
  • A beginner
What am I trying to achieve?
  • IN SHORT: I need to add new variables to products. IN LONG: I want to either extend the TableProducts class and add new variable to it, or be able to show certain custom fields without having to select them from a list, every time I create a product.
  • Somehow, I have to find a way to get the products I want from the database by using SQL queries of my own (they are quite complicated), without hacking files that will get overridden.

  • I've tried using MVC Override but I've had difficulties at early stages and I'm not sure that's the option I should use.
  • I've tried adding a new variable to TableProducts (/administrator/components/com_virtuemart/tables/products.php). But this is being overridden in any VirtueMart update.
  • In order to extend the product's variables, I'm thinking about creating a new table with all the variables I want, and attach a product_id to it. Similar to how custom fields work.
  • I've tried editing VirtueMartModelProduct class (/administrator/components/com_virtuemart/models/product.php) and changing SQL queries. This also wont be saved once VirtueMart udpates.
  • This is kinda wack, but I tried to create fields that when the product is being saved, are all converted into an array and inserted in a custom field. Then I can extract them in product view, but I still cant run queries on a product with this way.

I don't ask for code, or specifics, I only need to know what are my best options. I will figure the rest.
If i can't find a solution, I'll have to keep hacking core files (which is so hard to maintain) or simply keep using the same VirtueMart version.

PHP Version 5.6.30
Joomla Version 3.7.0
VirtueMart Version 3.0.16 (I'm about to update to the latest)
VirtueMart 3.0.16

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 819
  • VirtueMart Version: VM3 on J3
show certain custom fields without having to select them from a list, every time I create a product

You mean the dropdown on custom fields tab to add the fields to the product? Why is this to complicated? If you have a lot of fields you can add all this fields to a group and the only thing you need to do on new products is to choose this group on the dropdown and all fields are added to your product with one click.


  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9092
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
better is to use a product pattern, so you can easily change all products at once.
I should fix your bug, please support the VirtueMart project and become a member
Extensions approved by the core team:


  • Jr. Member
  • **
  • Posts: 81
  • A beginner
K&K media production, can I tweak with the search results to show me products by certain custom fields? Order by these fields? I really need make some major changes in the SQL.

Milbo, I'm not sure I get it.
VirtueMart 3.0.16

GJC Web Design

  • 3rd party VirtueMart Developer
  • Hero Member
  • *
  • Posts: 7485
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
product pattern

install somewhere the demo VM package with products and study how the various custom fields are configured
GJC Web Design
VirtueMart and Joomla Developers - php developers
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
Contact for any VirtueMart or Joomla development & customisation


  • Global Moderator
  • Super Hero
  • *
  • Posts: 10270
  • VirtueMart Version: 3+

what are the variables?

You can do a lot with custom fields. You can also do a lot with product plugins.

You can also add a custom

"Sort by Container" with your own links in it

then in your sublayout/products grab the parameter from the url, and sort by it.

I do NOT do development work for hire.