$token =
$this->ids->
create('token'
);
$options =
[ SalesChannelContextService::PERMISSIONS =>
[ ProductCartProcessor::SKIP_PRODUCT_STOCK_VALIDATION => false,
ProductCartProcessor::ALLOW_PRODUCT_PRICE_OVERWRITES => true,
],
];
$context =
$this->
getContainer()->
get(SalesChannelContextFactory::
class) ->
create($token, TestDefaults::SALES_CHANNEL,
$options);
$definition =
new QuantityPriceDefinition(10,
new TaxRuleCollection(), 1
);
$product =
$this->
getContainer()->
get(ProductLineItemFactory::
class) ->
create(['id' =>
$this->ids->
get('product'
), 'referencedId' =>
$this->ids->
get('product'
)],
$context);
$product->
setPriceDefinition($definition);
$product->
setLabel('My test product'
);
$product->
setQuantity(5
);
$cart =
$this->cartService->
getCart($token,
$context);
$this->cartService->
add($cart,
$product,
$context);
$this->cartService->
add($cart,
$product,
$context);