Created
November 15, 2019 15:14
-
-
Save aragon999/a205ca650c5e732e3a34551c0e76b540 to your computer and use it in GitHub Desktop.
[Shopware] Check if a media exists in the template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function smarty_modifier_swkweMediaExists($mediaPath) | |
{ | |
$mediaService = Shopware()->Container()->get('shopware_media.media_service'); | |
if ($mediaService->has($mediaPath)) { | |
return $mediaPath; | |
} else { | |
return ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Drop the file in
/themes/Frontend/<MyTheme>/_private/smarty/
, use it on a media path like the following:or