Adding new fields to product + changing SQL queries to retrieve a product

Started by OriyanJ, June 21, 2017, 11:15:33 AM

Previous topic - Next topic

OriyanJ

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.2.2

K&K media production

Quoteshow 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.

Milbo

better is to use a product pattern, so you can easily change all products at once.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

OriyanJ

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.2.2

GJC Web Design

Quoteproduct 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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

PRO

OriyanJ,

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.