0

I am not understanding the concept difference between collection and repository in magento2 and which is better to use.

your help will be able to appreciate.

1 Answer 1

0

Sort answer : They are the same.

Long answer : Repositories are in fact more abstract than collection. The same way as collection are more abstract than ResourceModel.

Collection used to be the magento 1 way. But they are still very used in magento 2, although we should all be using Repositories.

But at the end of the day, what you need to remind is that repositories are just an abstraction of collection, so when you call repository they will end up using collection at some point.

Repositories tend to be closer from the object side. When Collection tends to be closer from the sql / database side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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