I know we should use service contracts(Repository) over $model->load(), but in Repository itself, how to replace the deprecated load() function?
For example, in Magento\Cms\Model\PageRepository, the official Magento 2.1.9 used the deprecated load() function too.
public function getById($pageId)
{
$page = $this->pageFactory->create();
$page->load($pageId);
if (!$page->getId()) {
throw new NoSuchEntityException(__('CMS Page with id "%1" does not exist.', $pageId));
}
return $page;
}
Reference
When Should We Use a Repository and Factory in Magento 2?
Is there ever a reason to prefer $model->load() over service contracts?
Magento\Framework\EntityManager\EntityManager's load() method – Key Shang Dec 04 '17 at 03:21