modules/acm_sku/src/SKUFieldsManager.php
public function addFields() {
    $this->logger->info('addFields() invoked to add newly added base fields to SKU.');
    // Get all the additional fields from all custom modules.
    $fields = $this->getAllCustomFields();

    // Store the fields in config.
    $config = $this->configFactory->getEditable(self::BASE_FIELD_ADDITIONS_CONFIG);
    $existing_fields = $config->getRawData();

    $fields = array_diff_key($fields, $existing_fields);
    $existing_fields = array_merge($existing_fields, $fields);
    $config->setData($existing_fields)->save();

    if ($fields) {
      $this->logger->info('Adding new fields %fields.', [
        '%fields' => json_encode($fields),
      ]);

      // Apply entity updates, we will read from config and add/update fields.
      $this->entityDefinitionUpdateManager->applyUpdates();

      // Allow other modules to take some action after the fields are added.
      $this->moduleHandler->invokeAll('acm_sku_base_fields_updated', [$fields, 'add']);
    }
    else {
      $this->logger->warning('No new fields found to add.');
    }

  }
public function addFields() {
    $this->logger->info('addFields() invoked to add newly added base fields to SKU.');
    // Get all the additional fields from all custom modules.
    $fields = $this->getAllCustomFields();

    // Store the fields in config.
    $config = $this->configFactory->getEditable(self::BASE_FIELD_ADDITIONS_CONFIG);
    $existing_fields = $config->getRawData();

    $fields = array_diff_key($fields, $existing_fields);
    $existing_fields = array_merge($existing_fields, $fields);
    $config->setData($existing_fields)->save();

    if ($fields) {
      $this->logger->info('Adding new fields %fields.', [
        '%fields' => json_encode($fields),
      ]);

      // Apply entity updates, we will read from config and add/update fields.
      $this->entityDefinitionUpdateManager->applyUpdates();

      // Allow other modules to take some action after the fields are added.
      $this->moduleHandler->invokeAll('acm_sku_base_fields_updated', [$fields, 'add']);
    }
    else {
      $this->logger->warning('No new fields found to add.');
    }

  }
public function addFields ( ) { $ this -> logger -> info ( 'addFields() invoked to add newly added base fields to SKU.' ) ; // Get all the additional fields from all custom modules. $ fields = $ this -> getAllCustomFields ( ) ; // Store the fields in config. $ config = $ this -> configFactory -> getEditable ( self :: BASE_FIELD_ADDITIONS_CONFIG ) ; $ existing_fields = $ config -> getRawData ( ) ; $ fields = array_diff_key ( $ fields , $ existing_fields ) ; $ existing_fields = array_merge ( $ existing_fields , $ fields ) ; $ config -> setData ( $ existing_fields ) -> save ( ) ; if ( $ fields ) { $ this -> logger -> info ( 'Adding new fields %fields.' , [ '%fields' => json_encode ( $ fields ) , ] ) ; // Apply entity updates, we will read from config and add/update fields. $ this -> entityDefinitionUpdateManager -> applyUpdates ( ) ; // Allow other modules to take some action after the fields are added. $ this -> moduleHandler -> invokeAll ( 'acm_sku_base_fields_updated' , [ $ fields , 'add' ] ) ; } else { $ this -> logger -> warning ( 'No new fields found to add.' ) ; } }
Function to add all new field definitions from custom modules to SKU Base.
Function to add all new field definitions from custom modules to SKU Base .