Magento: Adding product-specific audio/video samples to the product page

Magento: Adding product-specific audio/video samples to the product page

August 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: Adding product-specific audio/video samples to the product page

Adding Product-Specific Audio/Video Samples to Magento Product Pages

In this blog post, we’ll explore how to integrate audio/video samples directly onto your Magento product pages without resorting to creating custom fields or treating the products as downloadable items. Our focus is on physical sheet music sellers who want to provide sound previews of their compositions.

Understanding the Challenge

The primary issue here is that you don’t want to treat the sheet music as a downloadable asset, yet you need to embed audio recordings on the product page. Traditional Magento downloadable products require an actual file attachment, which isn’t suitable for your use case since it doesn’t involve selling digital files.

Solution: Using Custom Product Attributes

The key lies in creating custom product attributes that can store the URL of the audio/video sample hosted elsewhere (like YouTube, SoundCloud, or a cloud storage service). We’ll then display these samples directly on the product page using some custom code.

Step-by-Step Guide

  1. Create Custom Attributes

    • Go to System > Configuration > Catalog > Attributes.
    • Click “Add New Attribute.”
    • Set the attribute name (e.g., audio_sample_url or video_preview_url), scope, and other details.
    • Save the attribute.
  2. Set the Attribute for Product Types

    • Under System > Configuration > Catalog > Catalog > Product Attributes.
    • Choose your product type (e.g., Simple Product).
    • Set “Used in Product Listing” to Yes and save.
  3. Add Samples to Products

    • Edit a product, go to the General section.
    • Scroll down to find the custom attribute you created.
    • Enter the URL of the audio/video sample hosted elsewhere (e.g., YouTube video ID or SoundCloud embed code).
  4. Display Samples on Product Page

    You’ll need to create a template override to display the samples using Magento’s layout XML and PHTML files.

    • In your theme directory, navigate to app/design/frontend/{Your_Vendor}/{Your_Theme}/template/catalog/product/view.
    • Create a new file called product.info.phtml or edit the existing one.
    • Find the section where you want to display the samples (usually inside the product details).
    <div class="audio-sample">
        <?php if ($product->getData('audio_sample_url')): ?>
            <!-- For audio files hosted on SoundCloud -->
            <iframe width="300" height="165" scrolling="no" frameborder="no" allow="autoplay" src="<?php echo $this->helper('core')->escapeHtml($product->getData('audio_sample_url')); ?>"></iframe>
        <?php endif; ?>
    </div>
    
    <div class="video-sample">
        <?php if ($product->getData('video_preview_url')): ?>
            <!-- For video files hosted on YouTube -->
            <iframe width="560" height="315" src="<?php echo $this->helper('core')->escapeHtml($product->getData('video_preview_url')); ?>" frameborder="0" allowfullscreen></iframe>
        <?php endif; ?>
    </div>
    
  5. Refresh the Cache

    • From the Magento admin, go to System > Tools > Cache Management.
    • Select all cache types and click “Flush Magento Cache.”

Conclusion

By utilizing custom product attributes and template overrides, you can successfully embed audio/video samples directly onto your Magento product pages without needing downloadable products or external modules.

Remember, if you’re looking for a more robust solution or need to handle complex e-commerce requirements, consider reaching out to experts at Laravel Company. They specialize in custom Magento development and can assist with projects requiring advanced features and integrations.

Catalog Database Configuration Errors

Our network