Skip to content

Commit 477c7f2

Browse files
committed
Issue #2870672 followup: Fix the mismatched field definition error by adding an update hook.
1 parent 202b8f8 commit 477c7f2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

modules/product/commerce_product.install

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Install, update and uninstall functions for the Product module.
66
*/
77

8+
use Drupal\Core\Field\BaseFieldDefinition;
9+
810
/**
911
* Change the path field to computed.
1012
*/
@@ -32,3 +34,28 @@ function commerce_product_update_8202() {
3234
$entity_type->set('entity_keys', $keys);
3335
$definition_update_manager->updateEntityType($entity_type);
3436
}
37+
38+
/**
39+
* Update the 'status' field.
40+
*/
41+
function commerce_product_update_8203() {
42+
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
43+
44+
$storage_definition = BaseFieldDefinition::create('boolean')
45+
->setName('status')
46+
->setTargetEntityTypeId('commerce_product')
47+
->setLabel(t('Published'))
48+
->setRevisionable(TRUE)
49+
->setTranslatable(TRUE)
50+
->setDefaultValue(TRUE)
51+
->setDisplayOptions('form', [
52+
'type' => 'boolean_checkbox',
53+
'settings' => [
54+
'display_label' => TRUE,
55+
],
56+
'weight' => 90,
57+
])
58+
->setDisplayConfigurable('form', TRUE);
59+
60+
$definition_update_manager->updateFieldStorageDefinition($storage_definition);
61+
}

0 commit comments

Comments
 (0)