I'm trying to get the User ID from Shipping Profile in Drupal Commerce using the following code, but eventually, $entity->getOwnerId() is returning me NULL in any case, if it's an authenticated user or admin it's giving me 0
as the UID.
function mymodule_entity_insert(EntityInterface $entity) {
if ($entity->getEntityTypeId() === 'profile') {
/** @var \Drupal\user\Entity\User $user */
$user = User::load($entity->getOwnerId());
}
}