The NodeTypeForm has a setting that allows you to change the default value of the status field (whether new nodes are published by default).
We should have that on the ProductTypeForm as well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dbolinovski created an issue. See original summary.

dbolinovski’s picture

mglaman’s picture

Status: Needs review » Needs work
  1. +++ b/modules/product/src/Form/ProductTypeForm.php
    @@ -84,6 +84,12 @@ class ProductTypeForm extends BundleEntityFormBase {
    +      '#description' => t('Whether products of this type should be published bu default.')
    

    s/bu/by

  2. +++ b/modules/product/src/Form/ProductTypeForm.php
    @@ -110,6 +116,13 @@ class ProductTypeForm extends BundleEntityFormBase {
    +    $fields = $this->entityManager->getFieldDefinitions('commerce_product', $this->entity->id());
    

    Since EntityManager is deprecated need to get service directly as \Drupal::service('entity_field.manager')->getFieldDefinitions()

  3. +++ b/modules/product/src/Form/ProductTypeForm.php
    @@ -110,6 +116,13 @@ class ProductTypeForm extends BundleEntityFormBase {
    +    $productType = $this->entityManager->getStorage('commerce_product')->create(['type' => $this->entity->id()]);
    

    EntityForm now supports $this->entityTypeManager. EntityManager is deprecated.

  4. +++ b/modules/product/src/Form/ProductTypeForm.php
    @@ -110,6 +116,13 @@ class ProductTypeForm extends BundleEntityFormBase {
    +    $this->entityManager->clearCachedFieldDefinitions();
    

    Replace EntityManager with \Drupal::service('entity_field.manager')

dbolinovski’s picture

Status: Needs work » Needs review
FileSize
1.92 KB
dbolinovski’s picture

entity_field.manager dependency injection.

mglaman’s picture

+1 for adding entity_field.manager as a dependency injection.

  • bojanz committed ff93e38 on 8.x-2.x authored by dbolinovski
    Issue #2619982 by dbolinovski: Change default value of the status field...
bojanz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.