Adding Banner To Magento Product Page

Adding Banner To Magento Product Page

October 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Adding Banner To Magento Product Page

Adding a Banner to Your Magento Product Page

Hello everyone! I’m excited to help you add a custom banner to your Magento product pages. In this guide, we’ll create a new attribute for the banners, enable uploading or linking images, and place them strategically on your template.

Step 1: Create a New Attribute for Banners

First, let’s create an attribute that will store the banner image information:

  1. Log in to your Magento admin panel.

  2. Navigate to Stores > Attributes > Product.

  3. Click “Add New Attribute.”

  4. Enter the following details:

    • Attribute Code: banner_image
    • Catalog Input Type for Store Owner: File (if you want to upload images)
    • Catalog Input Type for Store Admin: Text Field (if you want to enter image URLs)
  5. Click “Save Attribute.”

Step 2: Implement Banner Image in the Product Form

Next, we need to make this new attribute visible on the product edit form:

  1. Go to Stores > Attributes > Product.
  2. Find and click on banner_image.
  3. Set “Visible on Product View” to “Yes.”
  4. Click “Save Attribute.”

Step 3: Add Banner Image to Your Template

Now, let’s place the banner image in your product view template (usually located at app/design/frontend/your-theme/Magento_Catalog/templates/product/view.phtml).

Add this code snippet wherever you want the banner to appear:

<?php if ($product->getData('banner_image')): ?>
    <div class="custom-banner">
        <?php $imageUrl = $product->getBannerImage(); ?>
        <?php if (!empty($imageUrl)): ?>
            <img src="<?= $imageUrl ?>" width="100%" alt="<?= $block->escapeHtml(__('Custom Banner')) ?>">
        <?php endif; ?>
    </div>
<?php endif; ?>

In this code:

  • getData('banner_image') retrieves the banner image attribute.
  • $product->getBannerImage() fetches the actual banner image data.

Step 4: Uploading or Linking Banner Images

When editing a product, you’ll now see the new “Banner Image” field. You can either:

  1. Click “Browse…” to upload an image from your computer.
  2. Enter an image URL if you want to link to an external image.

Conclusion

And that’s it! Your Magento product pages should now be equipped with custom banners tailored to each item. This approach allows for easy management of different banners across products and ensures a professional look for your storefront.

Remember, always test changes thoroughly before deploying them live on your production site. If you’re facing any issues or need further assistance with Magento development, feel free to explore the resources available at Laravel Company for in-depth guides and expert consultation.

Happy customizing!

Catalog Themes Admin CLI

Our network