2

ロジック フックを作成しており、他のモジュール要素を使用して 1 つのモジュール フィールドを更新する必要があります。

<?php
class logic_hooks_class {

function after_save_method($bean, $event, $arguments) {

    if (!isset($bean->ignore_update_c)||$bean->ignore_update_c === false {

     //here I need to get module's reservations element: amount_reserved 
     //should I load relationship like $bean->load_relationship('reservations'); ??
     //need to set total_reserved = amount_reserved;
     //by the way amount_reserved might have several values for one reserved

          $bean->goods = $bean->amount-$bean->total_reserved;
          $bean->ignore_update_c = true;
          $bean->save();
  }
 }
}
?>
4

1 に答える 1

1

次のように関係の Bean をロードできます。

$bean->load_relationship('reservations');
$reservations = $bean->reservations->getBeans();

$reservationsこれで andをループしfetchて、必要な値を合計できます。

仕組みを明確にするためだけにload_relationship。のパラメーターload_relationshipは、関係の名前を指すリンク vardef にする必要があります。論理名は、予約と同様に、モジュールの複数形の名前です。

于 2015-01-10T11:14:31.680 に答える