Data Abstraction Layer
In contrast to most Symfony applications, Shopware uses no ORM but a thin abstraction layer called the data abstraction layer (DAL). The DAL is implemented with the specific needs of Shopware in mind and lets developers access the database via pre-defined interfaces. Some concepts used by the DAL, like Criteria, may sound familiar to you if you know Doctrine or other ORMs. A reference to more in-depth documentation about the DAL, can be found below.
An EntityRepository is used to interact with the DAL. This is the recommended way for developers to interface with the DAL or the database in general.
Provisioning code to use the repositories
Before using the repositories, you'll need to get them from the DIC. This is done with constructor injection, so you'll need to extend your services constructor by expecting an EntityRepositoryInterface:
// <plugin root>/src/Service/DalExampleService.php
public function __construct (EntityRepositoryInterface $productRepository)
$this->productRepository = $productRepository;
If you're using service autowiring, and the type and argument variable names are correct, the repository will be injected automatically.
Alternatively, configure the product.repository service to be injected explicitly:
// <plugin root>src/Resources/config/service.xml
<argument type="service" id="product.repository"/>
You can read more about dependency injection and service registration in Shopware in the services guides: