For that, you can use Magento\Cms\Api\GetBlockByIdentifierInterface. No need to use Magento\Framework\Api\SearchCriteriaBuilder. /** * @var \Magento\Cms\Api\GetBlockByIdentifierInterface */ private $blockByIdentifier; public function __construct( GetBlockByIdentifierInterface $blockIdentifier ) {
It’s easy to create a Cms Block via admin, but when code is moved to another server or in some cases of data loss, might