I'm trying to insert a template file as the content for the block I'm adding programmatically, but I'm not sure how this can be done. I've added the template file in view/frontend/templates/template-file.phtml
public function __construct(
BlockFactory $blockFactory,
Block $blockResourceModel
) {
$this->blockFactory = $blockFactory;
$this->blockResourceModel = $blockResourceModel;
}
/**
* {@inheritdoc}
*
* @return void
* @throws \Exception
*/
public function apply()
{
$cmsBlock = [
'title' => 'Footer content',
'identifier' => 'footer_content',
'content' => <How to insert template file here?>,
'is_active' => 1,
'store_id' => [9]
];
$block = $this->blockFactory->create();
$block->setData($cmsBlock);
$this->blockResourceModel->save($block);
}