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?
Asked
Active
Viewed 8,246 times
1 Answers
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?
-
Then, a factory to create a new object and repository to read and write existing objects in database? – Miguel Jun 02 '17 at 06:41
-
yes, it have that privilege .. – Amit Bera Jun 02 '17 at 07:15
-
before yo could load an object using factory but now load method is deprecated – Miguel Jun 02 '17 at 07:20