I am interested in adding a field to the 'Product' content type in Ubercart 3 / Drupal 7. I have read up on topics like field_create_field() and db_add_field()
but I want my field to be stored as an additional column in the uc_products
table in my database. In addition, I want my new field (qid) to be called whenever I call up the $node
value. How would I go about doing this?
-
2Altering a column in a table created by core or contrib is not a good idea unless you are very sure of what you are doing. For what purpose do you want this custom column?– bethCommented Mar 8, 2013 at 4:05
-
It's a quote field with a lot of important information about each individual product. I feel as though I have seen other contributed modules do this in the past.– kevinaskevinCommented Mar 8, 2013 at 12:23
-
1Why is its place in the database important to you?– bethCommented Mar 8, 2013 at 15:28
-
Thats a good question. It's more of a housekeeping issue. I guess I should be relying on the node api to sort through my fields and load / store my added field of qid, eh? Edit: I guess if I don't like using the node / field system I shouldn't be using Drupal in the first place :-/– kevinaskevinCommented Mar 8, 2013 at 16:06
Add a comment
|
1 Answer
This is no longer done in D7. You will want to use a proper field (which is stored in its own table and has many benefits over a simple column).
-
Thanks, this is what I have implemented and I now see the benefits of the field system. Commented Mar 12, 2013 at 13:22