Update entity properties fetched with entityTypeManager()->getStorage I am loading all entity types I need to update like below

$current_fruit = \Drupal::entityTypeManager()-&gt;getStorage('fruit')-&gt;loadByProperties(['status' =&gt; '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-&gt;name-&gt;getByValue("Apple);


and then I could just use

$fruit-&gt;set('price', $40);
$fruit-&gt;save();
You can actually use loadByProperties as that filter, you just need to extend your search:

$apples = \Drupal::entityTypeManager()
  -&gt;getStorage('fruit')
  -&gt;loadByProperties([
    'status' =&gt; '1', 
    'name' =&gt; 'Apple'
  ]);


If you need to filter an existing, broader list, then just use foreach, array_filter, etc; Drupal doesn't have any special methods for it.