How to display a static block in a popup in Magento 2

preview_player
Показать описание
► Skype: cuongnq87

Hi everybody, I am Cuong, Welcome back to my Magento 2 tutorial video series.
#magento2tutorial
Today, I am going to show everybody a best practice, How to display a static block in a popup in Magento 2.

What will you get after completing this practice? You will understand:
1. How to show a static block from a template phtml file in Magento 2
2. How to create a popup in Magento 2
3. How to add a block into a layout

Requirements: We are going to add a text link below the box select size and color on the product detail page. When the customer clicks this text link, the popup is going to show and displaying the content of a static block. This helps to consult the customer How to choose the right size for an item.

We will add the text link there.

Let's do this practice, you need to follow steps by step:

Step 1: Declaring a new module called PHPCuong_PopupContent
- Create the namespace PHPCuong in the path app\code.
- Create the module named PopupContent in the path app\code\PHPCuong.

End of the step #1, I have been completed the step to create a new module called PHPCuong_PopupContent.

Step 2: Create the new block
- Before creating a new block, we need to determine the layout file and the position we need to add this block.
- Let's determine the position we will add the new block, we need to enable the Template Path Hints for Storefront, Log into the backend and navigate to the STORES → Settings → Configuration → Advanced → Developer

Step 3: Create a new static block
- Log into the backend and navigate to the Content → Elements → Blocks → Add New Block
- Enter the block information

Step 4: Test and See the results
Run the commands line following:
php bin/magento setup:upgrade --keep-generated (Install the new modules)
php bin/magento cache:flush (flush caches)

Go to the product page.

Yeah, it works perfectly.

Thank you for your watching. If you have any questions about this practice please feel free to leave a comment below.

Don't forget to like, comment, share and subscribe to my channel for getting the latest videos.

Please do not hesitate to contact me if you need me to join your Magento project. My rate is $25/hour in Magento 1 and $30/hour in Magento 2.

Рекомендации по теме
Комментарии
Автор

Let's get a notification about the latest videos, please subscribe to my channel.

MagentoTutorial
Автор

Awesome,
Without voice, you did amazing.
Plz keep it up and teach more customizations.
Thanks

AshishKumar-whdw
Автор

Magento 2 documentation can be so easy to follow

phamyen
Автор

Awesome tutorial sir please upload more and more tutorial for Magento 2...

BestSuperHitSongs
Автор

Hello sir I have one issue for dresses how to choose the correct size is ok but same text is showing on mobiles products as well, here my point is the popup text need to show only for dresses not all the products how to resolve that issue

lokesht
Автор

Overall theme cutomization tutorial please upload...

Html Template through whole cutom theme in Magento 2... please

BestSuperHitSongs
visit shbcf.ru