magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Attribute getStoreLabel wrong behavior

Open Nuranto opened this issue 1 year ago • 11 comments

Preconditions and environment

  • Magento version 2.4.6-p2

Steps to reproduce

  1. Create any attribute, with a default label
  2. Set a different label for store id = X
  3. load attribute on admin area, and dump $attribute->getStoreLabel(X)

Expected result

Store label is dumped

Actual result

Default label is dumped

Additional information

The problem is quite obvious when watching the first method lines :

https://github.com/magento/magento2/blob/3cc15fbed80c1f75c77c7cfeeaaba3ca25fe81b8/app/code/Magento/Eav/Model/Entity/Attribute.php#L490-L495

A fix could be :

if (null === $storeId && $this->hasData('store_label')) { instead of if ($this->hasData('store_label')) {

But it's probably a bit more complicated than that, we probably want to use default value if store label is empty or not set

Workaround : $attribute->unsetData('store_label')->getStoreLabel($storeId);

Release note

No response

Triage and priority

  • [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [X] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Nuranto avatar Sep 04 '23 09:09 Nuranto

Hi @Nuranto. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

m2-assistant[bot] avatar Sep 04 '23 09:09 m2-assistant[bot]

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • [ ] 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • [ ] 5. Add label Issue: Confirmed once verification is complete.
  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Sep 11 '23 12:09 m2-assistant[bot]

Hello @Nuranto,

Thank you for the report and collaboration!

We have tried to reproduce the issue on 2.4-develop. But we got the expected result. We have created a custom module to dump the storeLabel in the admin panel. Please take a loot at the screenshot below: image image It can be observed that we are getting the store label of the specific website. Please find the custom module and let us know if we are missing anything. LabelVendor.zip

Thank you.

engcom-November avatar Sep 11 '23 12:09 engcom-November

What if you add another store, and you try to display the label of both stores ? Something like this in your block :

public function getLabel() {
        $this->attribute = $this->repository->get('test_attribute');
        var_dump($this->attribute->getStoreLabel(2));
        var_dump($this->attribute->getStoreLabel(3));
    }

Nuranto avatar Sep 11 '23 14:09 Nuranto

Hello @Nuranto,

Thank you for the quick response.

We have taken your input and tried to reproduce the issue, still we are getting the expected result. Please take a look at the below screenshot: image image We are able to get the store label of the second store as well. Please verify if the issue is reproducible on your end, and let us know if we are missing aything.

Thank you.

engcom-November avatar Sep 21 '23 08:09 engcom-November

Ok, I think I have the missing step.

In your block, load a product (of an attribute set that contains your test attribute) from product repository just before loading the attribute.

Nuranto avatar Sep 21 '23 14:09 Nuranto

Hello @Nuranto,

Thank you for the quick response!

As your input we loaded the attribute form the product itself, and not from the attribute repository. And the issue is reproducible. Please take a look at the screenshot below: image image It can be seen that even though we are dumping store labels of 2 different storeID, we are still getting the default label.

Please find below the custom module used to reproduce the issue. LabelVendor.zip

Thank you.

engcom-November avatar Sep 29 '23 08:09 engcom-November

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9631 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Sep 29 '23 08:09 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Sep 29 '23 08:09 m2-assistant[bot]

:x: You don't have permission to export this issue.

github-jira-sync-bot avatar Sep 29 '23 08:09 github-jira-sync-bot

@magento I am working on this

Kiraberos avatar Oct 13 '23 05:10 Kiraberos

Hello @Nuranto,

Re-verified this issue on 2.4-develop, issue is still present. We are still getting the default labels for all the store.

Thank you.

engcom-November avatar Jan 11 '24 13:01 engcom-November

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-9631

github-jira-sync-bot avatar Jan 11 '24 13:01 github-jira-sync-bot