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?

5

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?

  • Then, a factory to create a new object and repository to read and write existing objects in database? – Miguel Jun 2 '17 at 6:41
  • yes, it have that privilege .. – Amit Bera Jun 2 '17 at 7:15
  • before yo could load an object using factory but now load method is deprecated – Miguel Jun 2 '17 at 7:20

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.