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?
    – ZealousWeb
    Jun 24 at 12:02

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();?>

enter image description here

Block content will be displayed according to the store view you are in, i.e. English or German.

  • can we display only english block set for both? Jun 24 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.