Magento2: Custom category attributes scope not working

Created on 25 Oct 2016  路  10Comments  路  Source: magento/magento2

Preconditions

  1. Magento 2.1.2

    Steps to reproduce

  2. Add custom attribute to category with website scope:

    $categorySetup->addAttribute(
            Category::ENTITY, 'attrib_code', [
                'type' => 'int',
                'label' => 'Label',
                'input' => 'select',
                'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                'visible' => true,
                'required' => false,
                'sort_order' => 5,
                'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
                'group' => 'Content',
            ]
        );
  1. Add it to ui_component:
        <field name="attrib_code">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">boolean</item>
                    <item name="formElement" xsi:type="string">checkbox</item>
                    <item name="label" xsi:type="string" translate="true">Label</item>
                    <item name="prefer" xsi:type="string">toggle</item>
                    <item name="valueMap" xsi:type="array">
                        <item name="true" xsi:type="string">1</item>
                        <item name="false" xsi:type="string">0</item>
                    </item>
                    <item name="default" xsi:type="number">0</item>
                    <item name="sortOrder" xsi:type="number">5</item>
                </item>
            </argument>
        </field>

Expected result

  1. Custom attribute should be visible with scope [website]

    Actual result

  2. No scope label is visible, and attribute saves as it was set to store_view scope

Catalog Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x bug report

All 10 comments

I've the extended problem that if I set the attribute scope to SCOPE_STORE for example, and I have the backend scope set to "All Store Views" and I save the category with the changed attribute I get the SQL Error of Allowed memory size exhausted...

@Bartlomiejsz, thank you for your report.
The issue is already fixed in develop branch, 2.2.0

@magento-engcom-team can you point me to the commit that includes this fix?

@magento-engcom-team hey, I'm getting the problem in Magento 2.2.1 but that's OK.
Can you please point me and the guy above (@Tjitse-E ) to the commit that includes the fix?

Also getting this problem. 4 custom category attributes save store view specific, but aren't show that way in the category view. Any progress in the last few weeks @xpoback?

@SimonAnguish No real fix, only a temporary solution.
Since I had to overwrite the data provider model to apply this fix (which has beenreleased only in 2.2.4), I added my custom attribute code to the return result of the function here in the rewritten file, which seems to have helped at least with saving scope specific values. The label I added in the xml:
<item name="scopeLabel" xsi:type="string">[STORE VIEW]</item>

@magento-engcom-team Can you please post the commit hash or url for the fix? I'm experiencing same problem as others with version 2.2.3

Why do you ignore us???

Hi @engcom-backlog-nazar. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [ ] 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-97324, MAGETWO-97325 were created

@Bartlomiejsz, thank you for your report.

Unfortunately, we are archiving this ticket now as it did not get much attention from both Magento Community and Core developers for an extended period. This is done in an effort to create a quality, community-driven backlog which will allow us to allocate the required attention more easily.

Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.3-develop branch. Thank you for collaboration.

Was this page helpful?
0 / 5 - 0 ratings