I am loading all entity types I need to update like below
$current_fruit = \Drupal::entityTypeManager()->getStorage('fruit')->loadByProperties(['status' => '1']);
Then I update them in a way that I loop through the object and if particular value is matched I update some properties.
Thing is I am wondering is it possible to not loop through all of them, but just use some "magic" get method to find entity within loaded entities and then updated it, or is the foreach best method to do this? Something like
$fruit = $current_fruit->name->getByValue("Apple);
and then I could just use
$fruit->set('price', $40); $fruit->save();