Restore the Apply To field on product attribute forms (#21025) - #41222
Open
lbajsarowicz wants to merge 14 commits into
Open
Restore the Apply To field on product attribute forms (#21025)#41222lbajsarowicz wants to merge 14 commits into
lbajsarowicz wants to merge 14 commits into
Conversation
# Conflicts: # app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php # app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php
…on product edit form
# Conflicts: # app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php # app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php
Continues magento#27625 by @Bartlomiejsz. Bring the Apply To multiselect back to the Advanced Attribute Properties tab, so an attribute can again be limited to specific product types. Clearing the field is now explicit, because an empty multiselect posts no value at all and would otherwise keep the stored one. The product-page attribute popup is left unchanged: the Create Configurations wizard opens it and only accepts attributes applying to simple, virtual and configurable.
Contributor
Author
|
@magento run all tests |
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description (*)
Continues #27625 by @Bartlomiejsz, who has left the organization. His commits and authorship are preserved; the branch is merged with the current
2.4-develop.Since the product creation flow was streamlined, the Apply To field is gone from the product attribute form, so an attribute cannot be limited to specific product types from the admin any more. The storage and consumption side never went away:
apply_tois still a column,Savestill handles it for system attributes, and the product form modifier still filters attributes by it. In #21025 the product owner agreed (May 2020) that the field has to come back, and the issue was re-confirmed on2.4-developin February 2026.This PR brings the Apply To multiselect back to Stores > Attributes > Product > Advanced Attribute Properties:
Advancedblock:apply_tomultiselect fed by the newMagento\Catalog\Model\Attribute\Source\ApplyTooption source (ProductTypeListInterface), disabled for saved system attributes likeis_unique. The source is an optional trailing constructor parameter with an ObjectManager fallback, since the block is@api.Savecontroller: when a user-defined attribute is saved without any type selected,apply_tois explicitly set to an empty array. A cleared multiselect is not posted at all, so without this the stored value would silently survive.Changes on top of the original PR:
2.4-develop; the unit tests were rewritten upstream for PHPUnit 12 in the meantime, so the original test changes were replaced by tests that cover the new behaviour (field rendered with the source options, disabled for system attributes,apply_toreset when not posted, left untouched for system attributes)strict_typeson the controller)Why the popup stays without the field: the same
product_attribute_add_formis opened by the Create Configurations wizard, andConfigurableAttributeHandleronly accepts attributes whoseapply_tois empty or contains simple, virtual and configurable. Exposing Apply To there lets an admin create an attribute that vanishes from the wizard he just opened, which is the confusion reported during the original review. The attribute grid form is the place where the full type list is meaningful.Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
color): the field is shown read-only.Questions or comments
Gates run locally: unit (attribute block and controller suites, 56 tests), integration (attribute controller and block suites, 82 tests), PHPCS, PHPStan and the Static Tests
LiveCodeTeston the changed files are clean. Both new unit tests fail without the change and pass with it.The Semantic Version Checker will report the new optional constructor parameter on the
@apiblockAdvancedand the newApplyToclass.Contribution checklist (*)