I have created two stores english and german and created static blocks with different contents based on the store in admin.Block Id(test) for both stores are the same but both blocks assigned to respective stores...I need to call static block of english in phtml file. How can I do that?
if I use,$this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('test')->toHtml();
nothing will display.
-
Can you please post here your phtml file code?– ZealousWebJun 24, 2021 at 12:02
1 Answer
With the following test
blocks set in English and German stores I can display them in a phtml template with
<?php echo $block->getLayout()->createBlock(\Magento\Cms\Block\Block::class)->setBlockId('test')->toHtml();?>
Block content will be displayed according to the store view you are in, i.e. English or German.