// we split the context generation to allow caching of the base context
$base =
$this->baseContextFactory->
create($salesChannelId,
$options);
// customer
$customer = null;
if (\
array_key_exists(SalesChannelContextService::CUSTOMER_ID,
$options) &&
$options[SalesChannelContextService::CUSTOMER_ID
] !== null
) { // load logged in customer and set active addresses
$customer =
$this->
loadCustomer($options,
$base->
getContext());
} $shippingLocation =
$base->
getShippingLocation();
if ($customer) { /** @var CustomerAddressEntity $activeShippingAddress */
$activeShippingAddress =
$customer->
getActiveShippingAddress();
$shippingLocation = ShippingLocation::
createFromAddress($activeShippingAddress);
} $customerGroup =
$base->
getCurrentCustomerGroup();
if ($customer) { $criteria =
new Criteria([$customer->
getGroupId()]);
$criteria->
setTitle('context-factory::customer-group'
);