What is the difference between loading an order from OrderRepository & OrderFactory?


You need to understand the factory and repository patterns. Factories are service classes that instantiate non-injectable classes, that is, models that represent a database entity. They create a layer of abstraction between the ObjectManager and business code. Repositories are responsible for reading and writing your object information to an object store. In the Repository pattern, the data objects, the database logic, and the business logic connect to each other using interfaces.

Tip : Use repositories where possible and prefer them over factories.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.