Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getHreflangDefaultDomainId example
public
function
load
(
HreflangLoaderParameter
$parameter
)
: HreflangCollection
{
$salesChannelContext
=
$parameter
->
getSalesChannelContext
(
)
;
if
(
!
$salesChannelContext
->
getSalesChannel
(
)
->
isHreflangActive
(
)
)
{
return
new
HreflangCollection
(
)
;
}
$domains
=
$this
->
fetchSalesChannelDomains
(
$salesChannelContext
->
getSalesChannel
(
)
->
getId
(
)
)
;
if
(
$parameter
->
getRoute
(
)
=== 'frontend.home.page'
)
{
return
$this
->
getHreflangForHomepage
(
$domains
,
$salesChannelContext
->
getSalesChannel
(
)
->
getHreflangDefaultDomainId
(
)
)
;
}
$pathInfo
=
$this
->router->
generate
(
$parameter
->
getRoute
(
)
,
$parameter
->
getRouteParameters
(
)
, RouterInterface::ABSOLUTE_PATH
)
;
$languageToDomainMapping
=
$this
->
getLanguageToDomainMapping
(
$domains
)
;
$seoUrls
=
$this
->
fetchSeoUrls
(
$pathInfo
,
$salesChannelContext
->
getSalesChannel
(
)
->
getId
(
)
,
array_keys
(
$languageToDomainMapping
)
)
;
// We need at least two links
if
(
\
count
(
$seoUrls
)
<= 1
)
{
return
new
HreflangCollection
(
)
;
}