6.0.0 or newer

Table of contents

Reading entities from the storage is pretty straight-forward and does not require any special criteria object unless you already know what you are looking for.

The entity reader always works in batch mode, which means that you should not request entities one by one.

Reading entities

The entity repositories provide a search() method which takes two arguments:

  1. The Criteria object, which holds a list of ids in hex format.
  2. The Context object to be read with.
/** @var \Shopware\Core\Content\Product\ProductCollection $products */
$products = $productRepository->search(
    new Criteria([

The return value is a search result which has the entity collection containing all found entities as hydrated objects.