Import videos

As for every video, a preview image is needed as well, the video import, in general, is an extension of the image import.

Roles

For both, images and videos, Magento provides so called roles that can be used to define where the image or has to be rendered. If necessary, the default roles can dynamically be extended. Whenever a new role has been added, Pacemaker also has support for it by simply adding new columns that matches the role name.

By default, the following roles are available and can be used to define which role an imported image or video should have.

Role Description

base

The base image is the main image on the product detail page. Image zoom is activated if you upload an image that is larger image than the image container. Depending on the level of zoom that you want to achieve, the base image should be two or three times the size of the container. Example sizes: 470 x 470 pixels (without Zoom), 1100 x 1100 pixels (with Zoom)

small

The small image is used for the product images in listings on category and search results pages and to display the product images needed for sections such as for Up-sells, Cross-sells, and the New Products List. Example size: 470 x 470 pixels

thumbnail

Thumbnail images appear in the thumbnail gallery, shopping cart and in some blocks such as Related Items. Example size: 50 x 50 pixels

swatch

A swatch can be used to illustrate the color, pattern, or texture. Example size: 50 x 50 pixels

File Structure

The file structure for images and videos can be dynamically and depends on the roles an image has to be related with. For example, when only one image with the role base should be imported, it’s enough to have the columns base_image. The columns base_image_label and base_image_position are optional. For each additional role an image has to be related with, the additional columns are necessary, either it is the same image or not.

Column Name Type Description Example

<role>_image

varchar

The relative path to the image, starting with a slash (/).

/m/b/mb01-blue-0.jpg

<role>_image_label

varchar

The image label used as ALT text.

This is my image

<role>_image_position

integer

The position the image should be rendered in Admin backend and frontend.

1

additional_images

varchar

This column MUST contain a comma (,) separated list of relative paths to images.

/m/b/mb01-blue-0.jpg,/m/b/mb01-blue-1.jpg,/m/b/mb01-blue-2.jpg

additional_image_labels

varchar

This column MUST contain a comma (,) separated list of ALT texts for the images in the column additional_attributes whereas it MUST exactly have the same number of elements as additional images have been specified.

This is my image 1,,This is my image 2

additional_image_positions

integer

This column MUST contain a comma (,) separated list positions for the images in the column additional_attributes whereas it MUST exactly have the same number of elements as additional images have been specified.

1,3,2

<role>_video

text

The URL to the video that should be loaded, by default only videos from YouTube (needs an API key) or Vimeo are supported.

https://youtu.be/AzXrs1c92RY

<role>_video_title

varchar(255)

The title will be displayed on top of the video on the product detail page when the user hovers over the video.

Pacemaker Product Import

<role>_video_description

text

A description of the video which will be visible in the Admin backend only.

This video shows a simple M2IF product import in a Magento 2 shop instance.

<role>_video_provider

varchar(32)

The name of the video provider, actually one of YouTube or Vimeo .

YouTube

<role>_video_metadata

text

Additional metadata for the video that will be visible in the Admin backend only.

Pacemaker

additional_videos

varchar

This column MUST contain a comma (,) separated list of URLs to additional videos that should be loaded.

https://youtu.be/AzXrs1c92RY,https://vimeo.com/GxXrs1c92BY

additional_video_titles

varchar(255)

This column MUST contain a comma (,) separated list of titles for the videos in the column additional_videos whereas it MUST exactly have the same number of elements as additional videos have been specified. The titles will be displayed on top of the video on the product detail page when the user hovers over the video.

Pacemaker product import,A second video about product import

additional_video_descriptions

text

This column MUST contain a comma (,) separated list of descriptions for the videos in the column additional_videos whereas it MUST exactly have the same number of elements as additional videos have been specified. The descriptions will be visible in the Admin backend only.

Pacemaker product import,A second video about product import

additional_video_providers

varchar(32)

This column MUST contain a comma (,) separated list of provides for the videos in the column additional_videos whereas it MUST exactly have the same number of elements as additional videos have been specified. Actually one of YouTube or Vimeo can be used.

YouTube,Vimeo

additional_video_metadata

text

This column MUST contain a comma (,) separated list of metadata for the videos in the column additional_videos whereas it MUST exactly have the same number of elements as additional videos have been specified. The metadata will be visible in the Admin backend only.

YouTube,Vimeo

hide_from_product_page

varchar

Contains a comma (,) separated list of the relative image paths that should NOT be rendered on the product detail page, wheras it doesn’t matter if it is an image with a role or one of the additional images

/m/b/mb01-blue-0.jpg,/m/b/mb01-blue-2.jpg

disabled_images

varchar

Contains a comma (,) separated list of the relative image paths that should NOT be rendered anywhere, wheras it doesn’t matter if it is an image with a role or one of the additional images

/m/b/mb01-blue-0.jpg,/m/b/mb01-blue-2.jpg

If you currently want to import videos in the additional_videos column (which is almost always the case if videos are NOT base, small or thumbnail), the corresponding preview images in the additional_images column MUST be placed first, because the index of the images is used to assign the videos in the additional_videos column. Here is a small example:

Column additional_images /a/z/AzXrs1c92RY.jpg,/m/b/mb03-black-0_alt1.jpg

Column additional_videos https://youtu.be/AzXrs1c92R

During the import process, when the additional_videos column is unpacked, the value is assigned based on its index, i.e. the video with the URL https://youtu.be/AzXrs1c92RY has index 0 and is thus assigned to the image with index 0 in the addtional_images column, i.e. the image /a/z/AzXrs1c92RY.jpg. If the images in the column additional_images would now be reversed, i.e. /m/b/mb03-black-0_alt1.jpg,/a/z/AzXrs1c92RY.jpg then the video would be wrongly assigned to the image /m/b/mb03-black-0_alt1.jpg.

So the preview images of the videos must be in the additional_image column FIRST, otherwise the assignment does not work at the moment. The order in the additional_videos column must correspond to the order of the preview images, otherwise the assignment will not work. The actual order for the display in Admin backend and frontend can then be imported accordingly using the *_position columns.

Dedicated Media Import

Beside the possiblity to import videos, like images, with the product import itself, the Pacemaker professional edition comes with a command that allows a dedicated import of media files, which includes pictures and videos. To give you a better idea, we’ve a repository with sample data that contains a CSV file that only contains the necessary columns for a dedicated media import.

To run a dedicated media import and import a video for the product with the SKU 24-MB01, it is necessary to configure the YouTube API first, before the following command can be invoked.

cd <magento-install-dir> \
  && rm var/pacemaker/import/*.csv \
  && cp <sample-data-pro-dir>/* var/pacemaker/import \
  && vendor/bin/pacemaker import:products:media add-update \
    --clear-artefacts=false \
    --archive-artefacts=false \
    --serial=import \
    --source-dir=var/pacemaker \
    --target-dir=var/pacemaker

After refreshing the indexes, the video should be visibel on the product detail page on the frontend as well as in the Admin backen.