I have two variants adding data using Model. Which variant is more rignt ?
Especially I want to ask about this
$slider->setDataChanges(true);
in first variant because I must set up _hasDataChanges = true
if I want to save data.
2.Variant
As per Magento standard, the second option is right to add a new record to an entity using the repository.
If you want to update exist then you have to load the record by a primary key using getById()
$slider = $this->sliderRepository->getById('PKID'); $this->sliderRepository->save($slider);