In Magento 2 we have repositories classes. Classic method save()
used heavily in Magento 1.9 are deprecated, if I am correct, from 2.04 or 2.05. I was using factories to create new object and after setting properties of new, for example product i have called save()
:
$productFactory->create()->setName()...->save()
On the other hand we have repositories also containing method save()
. I am using it in nutshell like this:
$product = $productFactory->create()->setName()...
$productRepository->save($product)
In my code I have classes working both ways. I also have noticed that sometimes different ways means different behaviour. Has the way with repositories some additional validation of data provided?
Which way I should do it?