Hello everyone,
Objective: Add a video for each product and show it on product detail page.
Development type: Plugin
Explaination: 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 table. The plugin is able to add a video to each product in the backend.
Problem: 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 ?
My code:
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:
<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>