- Step 1: Generate a YouTube API Key
- Step 2: Integration of the YouTube API key to Magento 2
- Step 3: Integration of the YouTube Video URL to Product
Generate YouTube API Key
To generate a YouTube API Key, you need to Log in to your Google account first, and visit the Google Developers >> Open the Credentials page
You will get a window with an option to create a new project or you can add it to existing if you have already created a project with Google API.
Wait a few moments while the key is generated. You will need to fill up few basic information:
After hitting on Create button, you will have the option to generate API key:
Select API key
Please note here is one important option to consider. Press Restrict Key and restrict usage of this key only to specific domain. You can update API key name, restrict only to specific domain which you can add at the bottom. Hit Save.
Ok, great we have now API key. But we need to enable it. Go to APIS select in left menu Dashboard and click Enable APIS and Services >> Find Youtube Data API to enable it:
Now the final step is to enable and run API:
At the end, you will get dashboard with all information regarding API usage, and also you can disable API:
Integration of YouTube API key to Magento 2
Go to the Admin Panel of your Magento Store and navigate to the Store tab from the left corner of the page. Select Configuration from the options.
Now click on Catalog:
Go to Product Video section and insert the YouTube API key which we generated in Google Developers Console. Then click on Save Config.
Integration of YouTube Video URL to Product
Go to the Admin Panel of the Magento Store and navigate to the Products tab. Next, click the Catalog option.
Click on the Edit option of product.
Now go to the Images and Videos section of Product and click on Add Video >> Enter the Product video URL from YouTube and click on Save.
Now, just click on Save as shown in the image below:
Go back to the Product page and you will see the result.
Final Words
You can use the video feature to attract and convince the customer about the product. By following this tutorial, you'll be able to add video to products in Magento 2 store easily. If you have a problem or would like to have a further discussion, just leave a comment below.
Thanks for reading!