cancel
Showing results for 
Search instead for 
Did you mean: 

Static Block At The Top Of Product Page

Static Block At The Top Of Product Page

Is there a way to add a static block to the top of my product page, just beneath my navigation bar.

 

Thanks in advance.

4 REPLIES 4

Re: Static Block At The Top Of Product Page

You need to create one static block name product-topblock and set below content under the catalog_product_view.xml file,

Path is app/code/{Packagename}/{Modulename}/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    	<referenceContainer name="page.top">
        <block class="Magento\Cms\Block\Block" name="product-topblock" after="breadcrumbs">
			<arguments>
				<argument name="block_id" xsi:type="string">product-topblock</argument> 
			</arguments>			
		</block>
		</referenceContainer>
    </body>
</page>

 

 

 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Static Block At The Top Of Product Page

Hi,

 

Thank you for your reply, I do not seem to have a catalog_product_view.xml

Re: Static Block At The Top Of Product Page

You need to create below file at your theme level,

app/design/frontend/{Packagename}/{themename}/Magento_Catalog/layout/catalog_product_view.xml

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Static Block At The Top Of Product Page

Hello @steven_banks

 

why not use easy way?

 

you can create widget for that and you can call block there.

 

More info

https://blog.landofcoder.com/add-cms-block-magento-2/ 

 

Hope it will help you.

 

if work then marks as a solution or give kudos.

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer