Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setDownloads example
$order
=
new
OrderEntity
(
)
;
$lineItem
=
new
OrderLineItemEntity
(
)
;
$lineItem
->
setId
(
Uuid::
randomHex
(
)
)
;
$lineItem
->
setGood
(
true
)
;
$lineItem
->
setStates
(
[
State::IS_DOWNLOAD
]
)
;
$downloadId
= Uuid::
randomHex
(
)
;
$download
=
new
OrderLineItemDownloadEntity
(
)
;
$download
->
setId
(
$downloadId
)
;
$lineItem
->
setDownloads
(
new
OrderLineItemDownloadCollection
(
[
$download
]
)
)
;
$order
->
setLineItems
(
new
OrderLineItemCollection
(
[
$lineItem
]
)
)
;
yield
'grant access for order with downloadable line items' =>
[
$order
,
[
[
'id' =>
$downloadId
,
'accessGranted' => true,
]
,
]
,
]
;
if
(
isset
(
$similarProducts
[
$number
]
)
)
{
$product
->
setSimilarProducts
(
$similarProducts
[
$number
]
)
;
}
if
(
isset
(
$votes
[
$number
]
)
)
{
$product
->
setVotes
(
$votes
[
$number
]
)
;
}
if
(
isset
(
$downloads
[
$number
]
)
)
{
$product
->
setDownloads
(
$downloads
[
$number
]
)
;
}
if
(
isset
(
$links
[
$number
]
)
)
{
$product
->
setLinks
(
$links
[
$number
]
)
;
}
if
(
isset
(
$media
[
$number
]
)
)
{
$product
->
setMedia
(
$media
[
$number
]
)
;
}
if
(
isset
(
$properties
[
$number
]
)
)
{
$orderLineItem
->
setGood
(
true
)
;
$orderLineItem
->
setRemovable
(
false
)
;
$orderLineItem
->
setStackable
(
true
)
;
if
(
$toManipulate
=== 'order-add-line-item-download'
)
{
$orderLineItemDownload
=
new
OrderLineItemDownloadEntity
(
)
;
$orderLineItemDownload
->
setId
(
Uuid::
randomHex
(
)
)
;
$orderLineItemDownload
->
setMediaId
(
Uuid::
randomHex
(
)
)
;
$orderLineItemDownloadCollection
=
new
OrderLineItemDownloadCollection
(
)
;
$orderLineItemDownloadCollection
->
add
(
$orderLineItemDownload
)
;
$orderLineItem
->
setDownloads
(
$orderLineItemDownloadCollection
)
;
}
$orderLineItemCollection
=
new
OrderLineItemCollection
(
)
;
$orderLineItemCollection
->
add
(
$orderLineItem
)
;
// Order delivery position
$orderDeliveryPositionCollection
=
new
OrderDeliveryPositionCollection
(
)
;
$orderDeliveryPosition
=
new
OrderDeliveryPositionEntity
(
)
;
$orderDeliveryPosition
->
setId
(
'order-delivery-position-id-1'
)
;
$orderDeliveryPosition
->
setOrderLineItem
(
$orderLineItem
)
;
$orderDeliveryPosition
->
setPrice
(
new
CalculatedPrice
(
1, 1,
new
CalculatedTaxCollection
(
)
,
new
TaxRuleCollection
(
)
)
)
;