artaza/module-youtubelist

Add attribute on product and show list of videos

Maintainers

Package info

github.com/martinartaza/youtubelist

Type:magento2-module

pkg:composer/artaza/module-youtubelist

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 6

Open Issues: 0

dev-main 2025-08-02 00:06 UTC

This package is auto-updated.

Last update: 2026-03-30 01:53:49 UTC


README

Magento 2 PHP License

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

  • 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

Product Page YouTube Videos

Admin Configuration

Admin Configuration

Product Attribute Setup

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

  1. Download the module files
  2. Place them in app/code/Artaza/YoutubeList/
  3. Run the following commands:
bin/magento module:enable Artaza_YoutubeList
bin/magento setup:upgrade
bin/magento cache:flush

โš™๏ธ Configuration

1. YouTube API Key Setup

  1. Go to Stores > Configuration > Catalog > Catalog > Product Video
  2. Enter your YouTube API Key
  3. Save the configuration

2. Module Configuration

  1. Go to Stores > Configuration > Artaza > YouTube List
  2. Enable the module
  3. Configure additional settings as needed

๐Ÿ“ Usage

Adding YouTube Videos to Products

  1. Navigate to a Product: Go to Catalog > Products and edit any product
  2. Add YouTube URL: In the product form, find the "Youtube List" attribute
  3. 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
  1. 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 Data helper 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:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Follow coding standards: Run PHPCS before submitting
  4. Add tests: Include unit tests for new functionality
  5. 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:

  1. Check the documentation
  2. Review existing issues
  3. Create a new issue with detailed information

Made with โค๏ธ for the Magento 2 community