Skip to content

Attribute repository resets sourceModel for new attributes #10814

@adi3009

Description

@adi3009

When creating a new product attribute through code, product attribute repository save method resets source model to null or something else. Therefore a new attribute is created with an empty option (in case of select or multiselect input type). This happens only for new attributes not when updating exiting attributes.

Expected Result

It is expected that when some data is set on a model, repository should not change or reset it.

Preconditions

Magento Version 2.1.7 CE and EE

Product Attribute Repository

Example Code

Steps to reproduce

  • Copy Example/Catalog module into app/code directory.

  • Install module

    ./bin/magento module:enable "Example_Catalog"
    ./bin/magento setup:upgrade
    ./bin/magento setup:di:compile
    
  • Run command to create an example product attribute

    ./bin/magento example:catalog:create_attribute
    

Actual Result

  • In magento admin panel you should see attribute example_attribute_code of input type select having just an empty option.

  • Run the command again and you should see the attribute has options from source model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: doneReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.stale issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions