Adding a Single Product to a Static Block in Magento
Hello! If you’re new to Magento e-commerce development, adding a product to a static block can seem like a daunting task. I’m here to guide you through this process step-by-step.
What is a Static Block?
In Magento, a static block is a reusable piece of content that can be inserted into multiple pages or layouts throughout your store. It’s perfect for displaying promotional messages, product recommendations, or any other dynamic content.
Adding a Product to a Static Block
You don’t need to write any complex code to achieve this. Magento provides an intuitive interface for managing static blocks and their contents.
Step 1: Create a New Static Block
- Navigate to the admin panel of your Magento store.
- In the left-hand menu, select Content > Blocks.

- Click on the Add New Block button.
Step 2: Configure the New Block
In the Block Information section:
- Identifier: Give your block a unique name, like “homepage_product”.
- Title: Provide a title for the block, e.g., “Featured Product”.

Step 3: Add Your Product
Scroll down to the Content section:
- Click on the Show / Hide Editor button.
- In the editor toolbar, click on the Product icon (it looks like a shopping cart).

A new window will open. Here’s how to select your product:
-
Search for your desired product by entering its name or SKU.
-
Click on the checkbox next to the product you want to add.
-
Click OK.
The selected product will be inserted into the content area of your static block.
Step 4: Save and Apply the Block
- Click the Save Block button at the bottom of the page.
Assigning the Static Block to a Page
To display this block on a specific page, you’ll need to assign it to a layout update XML file:
- Navigate to your Magento store’s directory via FTP or SFTP.
- Look for the app/design/frontend/package/theme/layout folder (replace “package” and “theme” with your current theme).
- Open the layout XML file corresponding to the page where you want to display the block.
For example, if you want to add it to the homepage:
app/design/frontend/package/theme/Magento_Theme/layout/default.xml
- Add the following code inside the
<body>tag of that XML file:
<body>
<referenceContainer name="content">
<block class="Magento\Cms\Block\Block" block_id="homepage_product"/>
</referenceContainer>
</body>
Replace “homepage_product” with the identifier you chose for your static block.
- Save and upload the file back to your server.
Conclusion
Adding a single product to a Magento static block is surprisingly simple once you know where to look. By following these steps, you should now be able to display any product on any page of your store without having to write extensive code.
Remember, Magento’s built-in CMS allows for a lot of flexibility and customization without needing to dive into the core PHP files. If you ever find yourself needing more advanced functionality, consider reaching out to an experienced developer or agency like Laravel Company.
Happy coding!