function commerce_autosku_entity_prepare_view in Commerce AutoSKU 8.2
Implements hook_entity_prepare_view().
File
- ./
commerce_autosku.module, line 98 - Allows hiding of entity label fields and automatic label creation.
Code
function commerce_autosku_entity_prepare_view($entity_type_id, array $entities, array $displays, $view_mode) {
if ($entity_type_id != 'commerce_product_variation') {
return;
}
foreach ($entities as $entity) {
if ($entity->in_preview === TRUE && $entity instanceof ContentEntityInterface) {
$decorator = \Drupal::service('commerce_autosku.entity_decorator');
/** @var \Drupal\commerce_autosku\CommerceAutoSkuManager $decorated_entity */
$decorated_entity = $decorator
->decorate($entity);
if ($decorated_entity
->hasSku() && $decorated_entity
->autoSkuNeeded()) {
$decorated_entity
->setSku();
}
}
}
}