4

What is the difference between these two objects in magento2? (Factory and Repository) I have seen that they have almost the same methods. What proper use does one have?

Miguel
  • 569
  • 2
  • 15
  • 26

1 Answers1

10

Different between factory and repository

Factory definition:

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.

Definition of repository:

A repository object is responsible for reading and writing your object information to an object store

See more details at When Should We Use a Repository and Factory in Magento 2?

bayer
  • 342
  • 2
  • 10
Amit Bera
  • 77,456
  • 20
  • 123
  • 237