Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setHreflangUseOnlyLocale example
public
function
testProductWithOnlyOneDomain
(
)
: void
{
$productId
= Uuid::
randomHex
(
)
;
$languageId
=
$this
->
getContainer
(
)
->
get
(
'language.repository'
)
->
searchIds
(
new
Criteria
(
)
,
$this
->salesChannelContext->
getContext
(
)
)
->
firstId
(
)
;
static
::
assertNotNull
(
$languageId
)
;
$domain
=
new
SalesChannelDomainEntity
(
)
;
$domain
->
setId
(
Uuid::
randomHex
(
)
)
;
$domain
->
setUrl
(
'https://test.de'
)
;
$domain
->
setHreflangUseOnlyLocale
(
false
)
;
$domain
->
setLanguageId
(
$languageId
)
;
$this
->salesChannelContext->
getSalesChannel
(
)
->
getDomains
(
)
->
add
(
$domain
)
;
$this
->seoUrlRepository->
create
(
[
[
'id' => Uuid::
randomHex
(
)
,
'salesChannelId' =>
$this
->salesChannelContext->
getSalesChannel
(
)
->
getId
(
)
,
'languageId' =>
$this
->salesChannelContext->
getSalesChannel
(
)
->
getDomains
(
)
->
first
(
)
->
getLanguageId
(
)
,
'routeName' => TestProductSeoUrlRoute::ROUTE_NAME,
'foreignKey' =>
$productId
,
public
function
testGetHomeUrlSalesChannelIsExistingTwoDomain
(
)
: void
{
$criteria
=
new
Criteria
(
)
;
$criteria
->
addAssociation
(
'locale'
)
;
$languages
=
$this
->
getContainer
(
)
->
get
(
'language.repository'
)
->
search
(
$criteria
,
$this
->salesChannelContext->
getContext
(
)
)
->
getEntities
(
)
;
$domain
=
new
SalesChannelDomainEntity
(
)
;
$domain
->
setId
(
Uuid::
randomHex
(
)
)
;
$domain
->
setUrl
(
'https://test-sitemap.de'
)
;
$domain
->
setHreflangUseOnlyLocale
(
false
)
;
$domain
->
setLanguageId
(
$languages
->
first
(
)
->
getId
(
)
)
;
$this
->salesChannelContext->
getSalesChannel
(
)
->
getDomains
(
)
->
add
(
$domain
)
;
$domain
=
new
SalesChannelDomainEntity
(
)
;
$domain
->
setId
(
Uuid::
randomHex
(
)
)
;
$domain
->
setUrl
(
'https://test-sitemap.de/en'
)
;
$domain
->
setHreflangUseOnlyLocale
(
false
)
;
$domain
->
setLanguageId
(
$languages
->
last
(
)
->
getId
(
)
)
;
$this
->salesChannelContext->
getSalesChannel
(
)
->
getDomains
(
)
->
add
(
$domain
)
;