WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

Load an entity and then grab some values

Submitted by barnettech on Tue, 03/09/2021 - 15:32
 $results = \Drupal::entityQuery('app_voucher')
      ->range(0, 20000)
      ->execute();
foreach ($results as $result) {
      $messenger = \Drupal::messenger();
      $voucher_entity = \Drupal::entityTypeManager()->getStorage("app_voucher")->load($result);
      $voucher_id = $voucher_entity->voucher_id->getValue();
      $product_id = $voucher_entity->product_id->getValue();

}