Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
reloadAppSnippets example
]
)
;
$productExport
=
$this
->
createCsvExport
(
ProductExportEntity::ENCODING_UTF8,
$salesChannelId
,
$salesChannelDomainId
)
;
$context
= Context::
createDefaultContext
(
)
;
$this
->
loadAppsFromDir
(
__DIR__ . '/fixtures/theme'
)
;
$this
->
reloadAppSnippets
(
)
;
$criteria
=
new
Criteria
(
)
;
$criteria
->
addFilter
(
new
EqualsFilter
(
'technicalName', 'SwagTheme'
)
)
;
$themeId
=
$themeRepo
->
searchIds
(
$criteria
,
$context
)
->
firstId
(
)
;
static
::
assertNotNull
(
$themeId
)
;
$this
->
getContainer
(
)
->
get
(
Translator::
class
)
->
reset
(
)
;
$this
->
getContainer
(
)
->
get
(
SalesChannelThemeLoader::
class
)
->
reset
(
)
;
$themeService
->
assignTheme
(
$themeId
,
$salesChannelId
,
$context
, true
)
;
Uuid::
randomHex
(
)
,
TestDefaults::SALES_CHANNEL
)
;
$translator
=
$this
->
getContainer
(
)
->
get
(
Translator::
class
)
;
$themeService
=
$this
->
getContainer
(
)
->
get
(
ThemeService::
class
)
;
$themeRepo
=
$this
->
getContainer
(
)
->
get
(
'theme.repository'
)
;
$themeLoader
=
$this
->
getContainer
(
)
->
get
(
SalesChannelThemeLoader::
class
)
;
// Install the app
$this
->
loadAppsFromDir
(
__DIR__ . '/Fixtures/theme'
)
;
$this
->
reloadAppSnippets
(
)
;
// Ensure the default Storefront theme is active
$criteria
=
new
Criteria
(
)
;
$criteria
->
addFilter
(
new
EqualsFilter
(
'technicalName', 'Storefront'
)
)
;
$defaultThemeId
=
$themeRepo
->
searchIds
(
$criteria
,
$salesChannelContext
->
getContext
(
)
)
->
firstId
(
)
;
static
::
assertNotNull
(
$defaultThemeId
, 'Default theme not found'
)
;
$themeService
->
assignTheme
(
$defaultThemeId
,
$salesChannelContext
->
getSalesChannelId
(
)
,
$salesChannelContext
->
getContext
(
)
, true
)
;
// Inject the sales channel and assert that the original snippet is used
$translator
->
injectSettings
(
$salesChannelContext
->
getSalesChannelId
(
)
,