In Magento 2, which one is the difference between Magento\Catalog\Model\Product
and Magento\Catalog\Model\ProductRepository
?
Using both of them, seems they have the same methods, so I don't know when I should use one or the other.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIn Magento 2, which one is the difference between Magento\Catalog\Model\Product
and Magento\Catalog\Model\ProductRepository
?
Using both of them, seems they have the same methods, so I don't know when I should use one or the other.
I am not 100% deep knowledge of this.
But i am pretty sure that you should use
\Magento\Catalog\Api\ProductRepositoryInterface
As it can use for both api and model layer
See the magento document:
http://devdocs.magento.com/guides/v2.1/extension-dev-guide/service-contracts/service-contracts.html
How to implement service contract for a custom module in Magento 2?