Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CmsSectionEntity example
new
CustomerEntity
(
)
,
new
CashRoundingConfig
(
2, 0.01, true
)
,
new
CashRoundingConfig
(
2, 0.01, true
)
,
[
]
)
;
}
private
function
getCmsPage
(
SalesChannelProductEntity
$productEntity
)
: CmsPageEntity
{
$cmsPageEntity
=
new
CmsPageEntity
(
)
;
$cmsSectionEntity
=
new
CmsSectionEntity
(
)
;
$cmsSectionEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsBlockEntity
=
new
CmsBlockEntity
(
)
;
$cmsBlockEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
=
new
CmsSlotEntity
(
)
;
$cmsSlotEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
->
setSlot
(
json_encode
(
$productEntity
->
getTranslated
(
)
, \JSON_THROW_ON_ERROR
)
)
;
$cmsBlockEntity
->
setSlots
(
new
CmsSlotCollection
(
[
$cmsSlotEntity
]
)
)
;
$cmsSectionEntity
->
setBlocks
(
new
CmsBlockCollection
(
[
$cmsBlockEntity
]
)
)
;
new
CustomerEntity
(
)
,
new
CashRoundingConfig
(
2, 0.01, true
)
,
new
CashRoundingConfig
(
2, 0.01, true
)
,
[
]
)
;
}
private
function
getCmsPage
(
SalesChannelProductEntity
$productEntity
)
: CmsPageEntity
{
$cmsPageEntity
=
new
CmsPageEntity
(
)
;
$cmsSectionEntity
=
new
CmsSectionEntity
(
)
;
$cmsSectionEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsBlockEntity
=
new
CmsBlockEntity
(
)
;
$cmsBlockEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
=
new
CmsSlotEntity
(
)
;
$cmsSlotEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
->
setSlot
(
json_encode
(
$productEntity
->
getTranslated
(
)
, \JSON_THROW_ON_ERROR
)
)
;
$cmsBlockEntity
->
setSlots
(
new
CmsSlotCollection
(
[
$cmsSlotEntity
]
)
)
;
$cmsSectionEntity
->
setBlocks
(
new
CmsBlockCollection
(
[
$cmsBlockEntity
]
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setSlot
(
'product-box'
)
;
$slot
->
setType
(
'product-box'
)
;
$slot
->
setFieldConfig
(
$fieldConfig
)
;
$slot
->
getFieldConfig
(
)
;
$cmsBlock
=
new
CmsBlockEntity
(
)
;
$cmsBlock
->
setUniqueIdentifier
(
'block1'
)
;
$cmsBlock
->
setSlots
(
new
CmsSlotCollection
(
[
$slot
]
)
)
;
$cmsSection
=
new
CmsSectionEntity
(
)
;
$cmsSection
->
setUniqueIdentifier
(
'section1'
)
;
$cmsSection
->
setBlocks
(
new
CmsBlockCollection
(
[
$cmsBlock
]
)
)
;
$cmsPage
=
new
CmsPageEntity
(
)
;
$cmsPage
->
setSections
(
new
CmsSectionCollection
(
[
$cmsSection
]
)
)
;
$product
->
setCmsPage
(
$cmsPage
)
;
return
$slot
;
}
}