artaza / module-youtubelist
Add attribute on product and show list of videos
Package info
github.com/martinartaza/youtubelist
Type:magento2-module
pkg:composer/artaza/module-youtubelist
Requires
- magento/module-graphql: *
This package is auto-updated.
Last update: 2026-03-30 01:53:49 UTC
README
A powerful Magento 2 module that allows you to add YouTube video lists to your products. Display embedded videos, playlists, and individual videos with a beautiful carousel interface.
๐ Table of Contents
- Features
- Screenshots
- Installation
- Configuration
- Usage
- GraphQL API
- Testing
- Code Quality
- Architecture
- Contributing
โจ Features
- YouTube Video Integration: Add YouTube videos to any product
- Multiple Video Support: Support for playlists, individual videos, and embedded videos
- Beautiful UI: Responsive carousel interface for multiple videos
- GraphQL API: Full GraphQL support for headless implementations
- Admin Configuration: Easy setup through Magento admin
- YouTube API Integration: Automatic thumbnail and video data fetching
- Responsive Design: Works perfectly on desktop and mobile devices
๐ธ Screenshots
Product Page Display
Admin Configuration
Product Attribute Setup
๐ Installation
Method 1: Composer (Recommended)
composer require artaza/module-youtubelist bin/magento module:enable Artaza_YoutubeList bin/magento setup:upgrade bin/magento cache:flush
Method 2: Manual Installation
- Download the module files
- Place them in
app/code/Artaza/YoutubeList/ - Run the following commands:
bin/magento module:enable Artaza_YoutubeList bin/magento setup:upgrade bin/magento cache:flush
โ๏ธ Configuration
1. YouTube API Key Setup
- Go to Stores > Configuration > Catalog > Catalog > Product Video
- Enter your YouTube API Key
- Save the configuration
2. Module Configuration
- Go to Stores > Configuration > Artaza > YouTube List
- Enable the module
- Configure additional settings as needed
๐ Usage
Adding YouTube Videos to Products
- Navigate to a Product: Go to Catalog > Products and edit any product
- Add YouTube URL: In the product form, find the "Youtube List" attribute
- Enter YouTube URL: Add your YouTube URL in one of these formats:
Supported URL Formats:
- Playlist:
https://www.youtube.com/watch?v=SzZxQIOill4&list=PLDRI6kWi9D9K1TTYIJDUPIF6wt462thBL - Single Video:
https://www.youtube.com/watch?v=SzZxQIOill4 - Embed URL:
https://www.youtube.com/embed/SzZxQIOill4 - Multiple Videos: Separate multiple URLs with commas
Example:
https://www.youtube.com/watch?v=SzZxQIOill4&list=PLDRI6kWi9D9K1TTYIJDUPIF6wt462thBL
- Save the Product: The videos will automatically appear on the product page
Frontend Display
The module automatically displays:
- First Video: As the main embedded player
- Additional Videos: In a beautiful carousel below
- Thumbnails: Automatic YouTube thumbnails
- Responsive Design: Works on all devices
๐ GraphQL API
The module provides full GraphQL support for headless implementations:
Query Example
{
products(filter: { sku: { eq: "24-WB04" } }) {
items {
name
sku
youtube_videos {
url
image
}
}
}
}
Response Example
{
"data": {
"products": {
"items": [
{
"name": "Push It Messenger Bag",
"sku": "24-WB04",
"youtube_videos": [
{
"url": "https://www.youtube.com/embed/SzZxQIOill4",
"image": "https://img.youtube.com/vi/SzZxQIOill4/mqdefault.jpg"
},
{
"url": "https://www.youtube.com/embed/nqTFVFWa-n0",
"image": "https://i.ytimg.com/vi/nqTFVFWa-n0/mqdefault.jpg"
},
{
"url": "https://www.youtube.com/embed/W9P-ykNCNjE",
"image": "https://i.ytimg.com/vi/W9P-ykNCNjE/mqdefault.jpg"
}
]
}
]
}
}
}
๐งช Testing
The module includes comprehensive unit tests following Magento 2 standards.
Running Tests
# Run all tests vendor/bin/phpunit app/code/Artaza/YoutubeList/Test/Unit/ # Run specific test classes vendor/bin/phpunit app/code/Artaza/YoutubeList/Test/Unit/Helper/DataTest.php vendor/bin/phpunit app/code/Artaza/YoutubeList/Test/Unit/Model/Resolver/YoutubeVideosTest.php
Test Coverage
- โ
Helper Tests: Complete coverage of
Datahelper methods - โ Resolver Tests: Full coverage of GraphQL resolver
- โ ViewModel Tests: Product page view model testing
- โ Edge Cases: Null values, invalid URLs, empty responses
๐ฏ Code Quality
The module follows Magento 2 coding standards and best practices:
Code Standards
- โ PSR-4 Autoloading: Proper namespace structure
- โ Magento 2 Standards: Follows official coding guidelines
- โ PHPCS Compliance: Passes Magento 2 coding standards
- โ Type Declarations: Full PHP 8.1+ type support
- โ Documentation: Comprehensive PHPDoc blocks
Quality Checks
# Run coding standards check vendor/bin/phpcs --standard=Magento2 app/code/Artaza/YoutubeList/ # Auto-fix coding standards vendor/bin/phpcbf --standard=Magento2 app/code/Artaza/YoutubeList/
๐๏ธ Architecture
Module Structure
Artaza_YoutubeList/
โโโ composer.json # Composer configuration
โโโ registration.php # Module registration
โโโ README.md # Module documentation
โโโ Helper/
โ โโโ Data.php # Core YouTube API integration
โโโ Model/
โ โโโ Resolver/
โ โโโ YoutubeVideos.php # GraphQL resolver
โโโ ViewModel/
โ โโโ ProductPage.php # Product page view model
โโโ Setup/
โ โโโ Patch/
โ โโโ Data/
โ โโโ AddYoutubelistProductAttribute.php # Data patch for attribute
โโโ etc/
โ โโโ module.xml # Module definition
โ โโโ config.xml # Module configuration
โ โโโ acl.xml # Access Control List
โ โโโ catalog_attributes.xml # Product attribute definition
โ โโโ schema.graphqls # GraphQL schema
โ โโโ adminhtml/
โ โโโ system.xml # Admin configuration
โโโ view/
โ โโโ frontend/
โ โโโ layout/
โ โ โโโ catalog_product_view.xml # Product page layout
โ โโโ templates/
โ โ โโโ productPage.phtml # Frontend template
โ โโโ web/
โ โโโ css/
โ โ โโโ listyoutube.css # Frontend styles
โ โโโ js/
โ โ โโโ youtube-list.js # Frontend JavaScript
โ โโโ images/
โ โโโ youtube-logo.png # YouTube logo
โ โโโ play.png # Play button
โ โโโ arrow.svg # Carousel arrows
โโโ i18n/
โ โโโ es_CL.csv # Spanish translations
โโโ docs/
โ โโโ images/ # Documentation images
โโโ Test/
โโโ Unit/
โโโ phpunit.xml # PHPUnit configuration
โโโ README.md # Test documentation
โโโ Helper/
โ โโโ DataTest.php # Helper unit tests
โโโ Model/
โ โโโ Resolver/
โ โโโ YoutubeVideosTest.php # Resolver unit tests
โโโ ViewModel/
โโโ ProductPageTest.php # ViewModel unit tests
Key Components
- Helper (Data): Handles YouTube API calls and video processing
- GraphQL Resolver: Provides API access to video data
- ViewModel: Manages product page video display
- Template: Renders the video carousel interface
๐ค Contributing
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Follow coding standards: Run PHPCS before submitting
- Add tests: Include unit tests for new functionality
- Submit a pull request
Development Setup
# Install dependencies composer install # Run tests vendor/bin/phpunit app/code/Artaza/YoutubeList/Test/Unit/ # Check coding standards vendor/bin/phpcs --standard=Magento2 app/code/Artaza/YoutubeList/
๐ License
This module is licensed under the OSL 3.0 license.
๐ Support
For support, please:
- Check the documentation
- Review existing issues
- Create a new issue with detailed information
Made with โค๏ธ for the Magento 2 community


