function commerce_product_update_8205 in Commerce Core 8.2
Update entity keys for products and variations.
File
- modules/
product/ commerce_product.install, line 103 - Install, update and uninstall functions for the Product module.
Code
function commerce_product_update_8205() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
foreach ([
'commerce_product',
'commerce_product_variation',
] as $entity_type_id) {
$uid_storage_definition = $definition_update_manager
->getFieldStorageDefinition('uid', $entity_type_id);
$entity_type = $definition_update_manager
->getEntityType($entity_type_id);
$keys = $entity_type
->getKeys();
$keys['owner'] = 'uid';
$keys['uid'] = 'uid';
$entity_type
->set('entity_keys', $keys);
$definition_update_manager
->updateEntityType($entity_type);
$definition_update_manager
->updateFieldStorageDefinition($uid_storage_definition);
}
}