Computed field, how to acces Foreignkey's data
Hello, from a computed field I wanna to a typical bill-line calculation doing a multiplication price = quantity * fk_product_price How can I do that? I tried wihout luck. $node_field[0]['value'] = $node->field_quantitat[0]['value'] * $node->field_fk_producte[0]['value']......; Thank's!
$node_field[0]['value'] = $node->field_quantitat[0]['value'] * $node->field_fk_producte[0]['field_preu']['value']; I tried it without luck... any idea? field_ preu is the CCK field where the product price is saved. I think I need to change the node object to point the product object with the product node ID but I don't know how. Node BILL-LINE : $node->field_fk_producte[0][nid']['value']; Should point to node PRODUCT: $node->field_preu[0]['value']; Thank's _____ De: support-bounces@drupal.org [mailto:support-bounces@drupal.org] En nombre de Marolijo - Pol maresma Enviado el: dimarts, 8 / gener / 2008 10:51 Para: support@drupal.org Asunto: [support] Computed field, how to acces Foreignkey's data Hello, from a computed field I wanna to a typical bill-line calculation doing a multiplication price = quantity * fk_product_price How can I do that? I tried wihout luck. $node_field[0]['value'] = $node->field_quantitat[0]['value'] * $node->field_fk_producte[0]['value']......; Thank's! __________ Informacisn de NOD32, revisisn 2767 (20080106) __________ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com
Marolijo - Pol maresma ha scritto:
Hello, from a computed field I wanna to a typical bill-line calculation doing a multiplication price = quantity * fk_product_price
How can I do that? I tried wihout luck.
$node_field[0]['value'] = $node->field_quantitat[0]['value'] * $node->field_fk_producte[0]['value']......;
Thank's!
Exec "print_r($node)". Are there present field_quantitat and field_fk_producte ? What is fk_* ? M. -- Michel 'ZioBudda' Morelli michel@ziobudda.net Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.it MSN: michel@ziobuddalabs.it JABBER: michel@gmail.com
Hello, from a computed field I wanna to a typical bill-line calculation doing a multiplication price = quantity * fk_product_price How can I do that? I tried wihout luck. $node_field[0]['value'] = $node->field_quantitat[0]['value'] * $node->field_fk_producte[0]['value']......; Thank's!
Exec "print_r($node)". Are there present field_quantitat and field_fk_producte ?
Yes booth are present but I think I need the field_preu (price) stored on the producte (product) node type identified by the field_fk_producte. Is it possible to do that?
What is fk_* ?
I use the fk_ prefix on all node_related CCK fields to avoid confussion when I'm using views or adding new node_Relations to other content types. It comes from the Foreign Key on relational databases ( I know it isn' the way that Drupal Stores it but it's usefull to me). Thank's for all! Pol Maresma -- Michel 'ZioBudda' Morelli michel@ziobudda.net Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.it MSN: michel@ziobuddalabs.it JABBER: michel@gmail.com __________ Información de NOD32, revisión 2767 (20080106) __________ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com
Marolijo - Pol maresma ha scritto: > >>Hello, from a computed field I wanna to a typical bill-line > calculation doing a multiplication > >> price = quantity * fk_product_price > >> How can I do that? I tried wihout luck. > >> $node_field[0]['value'] = $node->field_quantitat[0]['value'] > * $node->field_fk_producte[0]['value']......; > >> Thank's! > > > Exec "print_r($node)". Are there present field_quantitat and > field_fk_producte ? > > Yes booth are present but I think I need the *field_preu* (price) > stored on the *producte* (product) node type identified by the > field_fk_producte. > Is it possible to do that? Use node_load() $product = node_load($node->field_fk_producte[0]['value']); use print_r($product) for the exact field/value of the node. M. -- Michel 'ZioBudda' Morelli michel@ziobudda.net Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.it MSN: michel@ziobuddalabs.it JABBER: michel@gmail.com
participants (2)
-
Davide Michel 'ZioBudda' Morelli -
Marolijo - Pol maresma