Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createMediaCustomField example
/** * @return array<string> */
private
function
createContent
(
)
: array
{
$ids
=
$this
->
createMedia
(
9
)
;
$mediaIds
=
$ids
->
all
(
)
;
foreach
(
[
'product', 'category', 'order'
]
as
$entity
)
{
$this
->
createMediaCustomField
(
$entity
)
;
$this
->
createMediaSelectCustomField
(
$entity
)
;
$this
->
createMediaMultiSelectCustomField
(
$entity
)
;
}
$product
=
new
ProductBuilder
(
$ids
, Uuid::
randomHex
(
)
, 100
)
;
$product
->
price
(
100
)
;
$product
->
customField
(
'custom_field_media_product',
$ids
->
get
(
'media-1'
)
)
;
$product
->
customField
(
'custom_field_media_select_product',
$ids
->
get
(
'media-2'
)
)
;
$product
->
customField
(
'custom_field_media_multi_select_product',
[
$ids
->
get
(
'media-2'
)
,
$ids
->
get
(
'media-3'
)
,
$ids
->
get
(
'media-4'
)
]
)
;
$products
=
[
$product
->
build
(
)
]
;