Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createProductStreams example
}
$this
->
createTestProduct
(
$productData
)
;
$criteria
=
new
Criteria
(
[
$this
->ids->
get
(
'seo-product'
)
]
)
;
$criteria
->
addAssociation
(
'categories'
)
;
/** @var ProductEntity $product */
$product
=
$this
->productRepository->
search
(
$criteria
, Context::
createDefaultContext
(
)
)
->
first
(
)
;
$this
->
createProductStreams
(
)
;
$this
->
createCategoryStreams
(
)
;
$product
->
setStreamIds
(
[
$this
->ids->
create
(
'stream_id_1'
)
]
)
;
$category
=
$this
->breadcrumbBuilder->
getProductSeoCategory
(
$product
,
$this
->salesChannelContext
)
;
$category2
=
$this
->breadcrumbBuilder->
getProductSeoCategory
(
$product
,
$this
->contextFactory->
create
(
'',
$this
->ids->
get
(
'sales-channel-2'
)
)
)
;
static
::
assertInstanceOf
(
CategoryCollection::
class
,
$product
->
getCategories
(
)
)
;
if
(
$hasCategories
)
{
static
::
assertInstanceOf
(
CategoryEntity::
class
,
$category
)
;
static
::
assertInstanceOf
(
CategoryEntity::
class
,
$category2
)
;