You still can do basically the same as load()
, save()
, and delete()
actions still exists in abstract model classes. They are however marked as deprecated
as magento moves CRUD methods to separate repositories
classes. But since directory model does not have them yet here are 2 ways of loading the region.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$region = $objectManager->create('Magento\Directory\Model\Region')
->load($regionId);
or with collection
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$region = $objectManager->create('Magento\Directory\Model\ResourceModel\Region\Collection')
->addFieldToFilter('region_id', ['eq' => $regionId])
->getFirstItem();
This is just proof-of-concept code. Direct use of object manager is discouraged so in your actual code you should inject the proper class with dependency injection in __construct()
class.