Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getVariation example
$criteria
->
setIds
(
[
$productId
]
)
;
$productEntity
=
$this
->
getContainer
(
)
->
get
(
'product.repository'
)
->
search
(
$criteria
,
$context
)
->
first
(
)
;
$subscriber
=
$this
->
getContainer
(
)
->
get
(
ProductSubscriber::
class
)
;
$productLoadedEvent
=
new
EntityLoadedEvent
(
$this
->
getContainer
(
)
->
get
(
ProductDefinition::
class
)
,
[
$productEntity
]
,
$context
)
;
$subscriber
->
loaded
(
$productLoadedEvent
)
;
$variation
=
$productEntity
->
getVariation
(
)
;
if
(
$sort
)
{
sort
(
$variation
)
;
sort
(
$expected
)
;
}
static
::
assertEquals
(
$expected
,
$variation
)
;
}
/** * @return array<mixed> */
'releaseDate' =>
$product
->
getReleaseDate
(
)
?
$product
->
getReleaseDate
(
)
->
format
(
Defaults::STORAGE_DATE_TIME_FORMAT
)
: null,
'isNew' =>
$product
->
isNew
(
)
,
'markAsTopseller' =>
$product
->
getMarkAsTopseller
(
)
,
'purchasePrices' =>
$purchasePrices
?
json_encode
(
$purchasePrices
, \JSON_THROW_ON_ERROR
)
: null,
'productNumber' =>
$product
->
getProductNumber
(
)
,
'manufacturerId' =>
$product
->
getManufacturerId
(
)
,
'taxId' =>
$product
->
getTaxId
(
)
,
'tagIds' =>
$product
->
getTagIds
(
)
,
'categoryIds' =>
$product
->
getCategoryTree
(
)
,
'propertyIds' =>
$product
->
getPropertyIds
(
)
,
'optionIds' =>
$product
->
getOptionIds
(
)
,
'options' =>
$product
->
getVariation
(
)
,
'streamIds' =>
$product
->
getStreamIds
(
)
,
'parentId' =>
$product
->
getParentId
(
)
,
'stock' =>
$product
->
getStock
(
)
,
]
;
$lineItem
->
replacePayload
(
$payload
,
[
'purchasePrices' => true
]
)
;
}
private
function
getPriceDefinition
(
SalesChannelProductEntity
$product
, SalesChannelContext
$context
, int
$quantity
)
: QuantityPriceDefinition
{
$this
->priceCalculator->
calculate
(
[
$product
]
,
$context
)
;
static
::
assertImportExportSucceeded
(
$progress
,
$this
->
getInvalidLogContent
(
$progress
->
getInvalidRecordsLogId
(
)
)
)
;
$criteria
=
new
Criteria
(
)
;
$criteria
->
addAssociation
(
'options.group'
)
;
$criteria
->
addAssociation
(
'configuratorSettings'
)
;
$criteria
->
addFilter
(
new
EqualsFilter
(
'parentId', 'e5c8b8f701034e8dbea72ac0fc32521e'
)
)
;
/** @var ProductEntity $result */
$result
=
$this
->productRepository->
search
(
$criteria
, Context::
createDefaultContext
(
)
)
->
first
(
)
;
static
::
assertCount
(
2,
$result
->
getVariation
(
)
)
;
$criteria
->
resetFilters
(
)
;
$criteria
->
addFilter
(
new
EqualsFilter
(
'id', 'e5c8b8f701034e8dbea72ac0fc32521e'
)
)
;
/** @var ProductEntity $result */
$result
=
$this
->productRepository->
search
(
$criteria
, Context::
createDefaultContext
(
)
)
->
first
(
)
;
static
::
assertInstanceOf
(
ProductConfiguratorSettingCollection::
class
,
$result
->
getConfiguratorSettings
(
)
)
;
static
::
assertCount
(
2,
$result
->
getConfiguratorSettings
(
)
)
;
}