WHAT I NEED TO ACCOMPLISH?
I'd like to add new variables to the product's class, I've noticed that administrator\components\com_virtuemart\tables\products.php extends VmTable and I'd like to know if there's any way I can add my own variables by override or extending it while they'll be safe from VirtueMart updates.
WHY?
I've added new database fields to the product's table and at VirtueMart's back-office.
Yes you can add your variables to products.php if you like, that is the joy of open source!
Add them after:-
/** @var int published or unpublished */
var $published = 1;
and before:-
function __construct($db) {
they'll be safe from VirtueMart updates
You will have to re-apply your changes to this file after every VM update as the code changes will be overwritten.
I have my own set of around 10 fields that I "manage" in this manner - updates have never affected them in the database - Give them some unique field prefix just to make sure!
You should then add some overrides to the product admin template to allow these variables to be seen/adjusted:-
I would put them in their own tab:-
To add a new tabEdit this file:-
administrator\templates\isis\html\com_virtuemart\product\product_edit.php
Add the new tab name and the file it should open.
$tabarray['mynewstuff'] = 'MY new stuff'; //added by you
To get the new stuff into that tabCreate yourself the file to load the new fields - using the "mynewstuff" example from above, the file will be named:-
administrator\templates\isis\html\com_virtuemart\product\product_edit_mynewstuff.php
Then add your data to this tab (follow the example of one of the existing tabs)
To get at your new variables in the front end:$this->product->your_new_field