private function searchPromotionsByCodes(CartDataCollection
$data, array
$allCodes, SalesChannelContext
$context): CartPromotionsDataDefinition
{ $keyCacheList = 'promotions-code';
// create a new cached list that is empty at first
if (!
$data->
has($keyCacheList)) { $data->
set($keyCacheList,
new CartPromotionsDataDefinition());
} // load it
/** @var CartPromotionsDataDefinition $promotionsList */
$promotionsList =
$data->
get($keyCacheList);
// our data is a runtime cached structure.
// but when line items get removed, the collect function gets called multiple times.
// in the first iterations we still have a promotion code item
// and then it is suddenly gone. so we also have to remove
// entities from our cache if the code is suddenly not provided anymore.