How to create a Static block for custom module creation in magento2
Thanks
How to create a Static block for custom module creation in magento2
Thanks
Try this in your install/upgrade script.
<?php
...
private $blockFactory;
public function __construct(
\Magento\Cms\Model\BlockFactory $blockFactory
)
{
$this->blockFactory = $blockFactory;
}
...
...
$testBlock = [
'title' => 'Test block title',
'identifier' => 'test-block',
'stores' => [0],
'is_active' => 1,
'content' => 'Test block content'
];
$this->blockFactory->create()->setData($testBlock)->save();