Get cms block by identifier – Magento 2

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
    ) {
        $this->blockByIdentifier = $blockIdentifier   
    }

Now you can get that page data passing blockIdentifier and storeId.

$this->blockByIdentifier->execute($blockIdentifier, $storeId);

 

Need Further Help? or Questions?

Contact Us

Create your account

chatsimple