# Add video to each product using s\_articles\_attributes.

**URL:** <https://forum.shopware.com/t/add-video-to-each-product-using-s-articles-attributes/52257>\
**Category:** Programmierung\
**Created:** [9. April 2018 um 10:32 UTC](https://forum.shopware.com/t/add-video-to-each-product-using-s-articles-attributes/52257 "2018-04-09T10:32:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tashfeen](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@tashfeen](https://forum.shopware.com/u/tashfeen)\
**Post date:** [9. April 2018 um 10:32 UTC](https://forum.shopware.com/t/add-video-to-each-product-using-s-articles-attributes/52257/1 "2018-04-09T10:32:17Z")

</div>

Hello everyone,

**Objective:&nbsp;** Add a video for each product and show it on product detail page.

**Development type:** Plugin

**Explaination:&nbsp;** I am trying to add a video for each product so it is available in the frontend detail page of the plugin. I am extending **s\_articles\_attributes&nbsp;** table. The plugin is able to add a video to each product in the backend.

**Problem:&nbsp;** When I try to fetch the video link in the frontend it appears as an integer and not as a link. How can I make it available as a link in the frontend detail template ?

&nbsp;

**My code:&nbsp;&nbsp;**

```
 public function install(InstallContext $context) { $attributeService = $this-\>container-\>get('shopware\_attribute.crud\_service'); $attributeService-\>update('s\_articles\_attributes', 'prod\_video', 'single\_selection', ['displayInBackend' =\> true, 'entity' =\> Media::class, 'label' =\> 'Product Video']); $this-\>container-\>get('models')-\>generateAttributeModels(['s\_articles\_attributes']); $context-\>scheduleClearCache(InstallContext::CACHE\_LIST\_ALL); }

```

**At frontend:**

&nbsp;

```
<video controls>
    {if !empty($sArticle['prod_video'])}
        <source src="%7B%24sArticle%5B'prod_video'%5D%7D" type="video/mp4">

    {else}
        <source src="http://somerandom.mp4" type="video/mp4">

    {/if}

    Your browser does not support the video tag.
</source></source></video>
```

---

<div class="post-metadata">

**Author:** ![derwunner](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@derwunner](https://forum.shopware.com/u/derwunner)\
**Post date:** [10. April 2018 um 06:25 UTC](https://forum.shopware.com/t/add-video-to-each-product-using-s-articles-attributes/52257/2 "2018-04-10T06:25:12Z")

</div>

Hi,

&nbsp;

it’s a bit wrong. It’s under the attributes key inside sArticle, so in Smarty it will look like this:

```
{$sArticle.attributes.core->get('prodvideo')}

```

I’m not sure, if this calls is 100% correct. But basically, you call arrays in Smarty with the dot notation. Object are called as in php with the arrow. Under attributes you got all your attributes in a few objects.

---

<div class="post-metadata">

**Author:** ![tashfeen](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@tashfeen](https://forum.shopware.com/u/tashfeen)\
**Post date:** [10. April 2018 um 07:25 UTC](https://forum.shopware.com/t/add-video-to-each-product-using-s-articles-attributes/52257/3 "2018-04-10T07:25:56Z")

</div>

Hello derwunner,

Thanks for your reply. I tried your suggested solutions still but no luck. The smarty debug console also shows the value as “571” and not as the video url/location.&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![derwunner](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@derwunner](https://forum.shopware.com/u/derwunner)\
**Post date:** [10. April 2018 um 13:54 UTC](https://forum.shopware.com/t/add-video-to-each-product-using-s-articles-attributes/52257/4 "2018-04-10T13:54:14Z")

</div>

That’s your media id. You need to get the corresponding dataset from s\_media. Then you got the virtual path, so you need to parse into an real url using the media serivce:&nbsp;[MediaService](https://developers.shopware.com/developers-guide/shopware-5-media-service/#handling-virtual-paths)
