0

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.

1
  • Can you please post here your phtml file code?
    – ZealousWeb
    Commented Jun 24, 2021 at 12:02

1 Answer 1

0

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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