From 920f4aa0a7bf82c8f459296dab824c6eb2cb17ae Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Thu, 23 May 2019 12:32:12 +0200 Subject: [PATCH] New Feature: CMS Block in Checkout based on stackoverflow https://magento.stackexchange.com/questions/173324/magento-2-add-cms-static-block-to-checkout-address-form --- Model/CmsBlockCheckoutConfigProvider.php | 55 +++++++++++++++++++ README.md | 66 +++++++++++++++++++++++ etc/frontend/di.xml | 20 +++++++ view/frontend/web/template/cms-block.html | 1 + 4 files changed, 142 insertions(+) create mode 100644 Model/CmsBlockCheckoutConfigProvider.php create mode 100644 etc/frontend/di.xml create mode 100644 view/frontend/web/template/cms-block.html diff --git a/Model/CmsBlockCheckoutConfigProvider.php b/Model/CmsBlockCheckoutConfigProvider.php new file mode 100644 index 0000000..a45b9db --- /dev/null +++ b/Model/CmsBlockCheckoutConfigProvider.php @@ -0,0 +1,55 @@ +cmsBlockWidget = $block; + $block->setData('block_id', $blockId); + $block->setTemplate('Magento_Cms::widget/static_block/default.phtml'); + } + + public function getConfig() + { + if (!$this->cmsBlockWidget) { + return []; + } + + return [ + 'cmsBlockHtml' => $this->cmsBlockWidget->toHtml() + ]; + } +} \ No newline at end of file diff --git a/README.md b/README.md index f022acf..89b514b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Magento2 Module Mestrona_CommonBlocks ===================================== +This module is intended for developers. + Magento 2 Module with simple basic blocks * Store Information @@ -8,6 +10,8 @@ Templates * store_information.phtml - Address and Store Hours, for example for the footer * store_information/contact.phtml - Phone and Email Links +* CMS Block for Checkout + Planed: * System Version (and maybe Git branch) @@ -35,11 +39,73 @@ Example: template="Mestrona_CommonBlocks::store_information.phtml" /> +CMS Block for Checkout +---------------------- + +Add to your frontend/di.xml + + + + identifier or ID of the block goes here + + + + +Add something like this to your checkout_index_index.xml (depends were you want to place the block) + + + + + + + + + + + + + + + + + + + + uiComponent + + Mestrona_CommonBlocks/cms-block + + 125 + + + + + + + + + + + + + + + + + + + + + About Us ======== [Mestrona GbR](http://www.mestrona.net/) offers Magento open source modules. If you are confronted with any bugs, you may want to open an issue here. +This module was co-developed with [iMi digital](https://github.com/iMi-digital). + In need of support or an implementation of a modul in an existing system, [free to contact us](mailto:support@mestrona.net). In this case, we will provide full service support for a fee. Of course we provide development of closed-source moduls as well. + + diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml new file mode 100644 index 0000000..49c0e7d --- /dev/null +++ b/etc/frontend/di.xml @@ -0,0 +1,20 @@ + + + + + + + Mestrona\CommonBlocks\Model\CmsBlockCheckoutConfigProvider + + + + + + \ No newline at end of file diff --git a/view/frontend/web/template/cms-block.html b/view/frontend/web/template/cms-block.html new file mode 100644 index 0000000..35906aa --- /dev/null +++ b/view/frontend/web/template/cms-block.html @@ -0,0 +1 @@ +
\ No newline at end of file