News:

Looking for documentation? Take a look on our wiki

Main Menu

added field in #__virtuemart_products

Started by guardiano78, July 24, 2015, 18:57:26 PM

Previous topic - Next topic

guardiano78

Hello,
i added at the end of table a new field named "category_option".

now i need to add this new field at the query select for obtain this result:

$product->category_option //for products list
$this->product->category_option //for product detail


where are the queries to modify?

AH

You need to change the product model, then your new product level field will be available


The file is :-

administrator/components/com_virtuemart/tables/products.php

class TableProducts extends VmTable {

var $category_option = null;  or whatever you want the default value to be


I would change the name to as such a name might used by core VM

maybe guardino_category_option



Regards
A

Joomla 4.4.5
php 8.1


Studio 42

Hi Hutson and guardiano,
I don't understand why you hack the core and why Hutson give the answer to change core fields, this is the best way to block all future updates !
SImply reuse an existing field eg meta author or another one. You are sure you can always upgrade then.
If you need to change the title, then use Joomla language overide.

AH

Quotethis is the best way to block all future updates

Good point, I agree that modifying core files and programs is not advisable as it can limit you in the future, however this is open source software and, as such, lends itself to modifications of this type.

Guardiano has already added the field to the database and was asking how to get this data to the product and category pages

Modifying the products.php will NOT block all future updates - the modification will have to be re-applied after every update to VM

Re-using an existing field can be problematic - unless you understand exactly where and how the system uses that field

It would have been better if we knew the business reason why such a field was required - we may have then been able to suggest an alternative.
Regards
A

Joomla 4.4.5
php 8.1

guardiano78

#5
Hello Studio 42,
for my projects ecommerce I have the need to interact with our management software for companies directly with the website through scripts exchange data I created.
To do that I need to include my custom fields in virtuemart database

Anyway, this is the only hack i need for the core