// check if promotion is already cached
if ($promotionsList->
hasCode($code)) { continue;
} // fetch that new code
$codesToFetch[] =
$code;
// add a new entry with null
// so if we cant fetch it, we do at least
// tell our cache that we have tried it
$promotionsList->
addCodePromotions($code,
[]);
} // if we have new codes to fetch
// make sure to load it and assign it to
// the code in our cache list.
if (\
count($codesToFetch) > 0
) { $salesChannelId =
$context->
getSalesChannel()->
getId();
foreach ($codesToFetch as $currentCode) { // try to find a global code first because
// that search has less data involved