Default domain values not being assigned

Created on 11 October 2018, over 5 years ago
Updated 27 June 2024, 2 days ago

Using this with Commerce and at /admin/config/domain/entities/commerce_order, I select:

- "Enable domain entity access" for each order type.
- Under "Choose which behavior must be used with the bundle ...", I choose "Affiliate automatically created entity to a value"
- Under "default domain value(s) for the bundle", I select the domain I want

When an order is created, the default is not applied. I can go in the store management side and assign it manually and it works after that, but obviously I can't have that done every time a customer creates an order. I need these defaults to work the way it seems they should or could someone explain what I'm doing wrong?

Thanks!

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dchaffin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mtalt Maryland

    I have run into a similar issue where default domain values are not being assigned. I am on 8.x-1.0-rc1 of the module. The settings for the entity are:

    1. Enable domain entity access
    2. Behavior is set to User
    3. Check any combination of default domain value(s) for the bundle

    This portion of the patch in #4 fixes the issue:

    function domain_entity_field_default_domains(FieldableEntityInterface $entity, FieldDefinitionInterface $definition) {
     -  return $definition->getThirdPartySetting('domain_entity', 'domains', []);
     +  return array_keys($definition->getThirdPartySetting('domain_entity', 'domains', []));
    }
    

    The current code results in only the first domain listed being set. This occurs because the array returned by the third party setting is keyed with strings instead of numerically. In Drupal Core's FieldInputValueNormalizerTrait::normalizeValue method, if the keys are not numeric, it will re-key all values under the 0 key. That results in only 1 of the selected default domains being set.

  • πŸ‡¨πŸ‡³China hongqing

    @mtalt do you only change the one line code? I tried it but it does not work. I granted the users the permissions to create products on assigned domains.

Production build 0.69.0 2024