Skip to content

Add scopehint on the category edit form - #27

Open
thedotwriter wants to merge 1 commit into
avstudnitz:masterfrom
thedotwriter:feature/scopehint-on-category-form
Open

Add scopehint on the category edit form#27
thedotwriter wants to merge 1 commit into
avstudnitz:masterfrom
thedotwriter:feature/scopehint-on-category-form

Conversation

@thedotwriter

Copy link
Copy Markdown

Hi,

Here's a feature I really wanted from this module. I adapted the \AvS\ScopeHint\Plugin\ProductEavDataProviderPlugin for the category edit form. I tried to stay close to the module coding style.

Check it out and tell me what you think.

Cheers

@sprankhub sprankhub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this! I commented two minor things, which I found :) I wouldn't consider them necessary, though.

Comment thread Plugin/CategoryFieldPlugin.php
Comment thread Plugin/CategoryFieldPlugin.php
@thedotwriter

Copy link
Copy Markdown
Author

Hi @avstudnitz, do you consider merging this feature or is it a no-go?

$this->registry = $registry;
$this->categoryRepository = $categoryRepository;
$this->escaper = $escaper;
}

@rubenromao rubenromao Mar 11, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @thedotwriter
I would use the "constructor property promotion" introduced in PHP 8.0.
the properties are declared directly in the constructor which is a more concise and clean way to define class properties.
Example:

class CategoryFieldPlugin
{
    /**
     * @param StoreManagerInterface $storeManager
     * @param Registry $registry
     * @param CategoryRepositoryInterface $categoryRepository
     * @param Escaper $escaper
     */
    public function __construct(
        public readonly StoreManagerInterface $storeManager,
        public readonly Registry $registry,
        public readonly CategoryRepositoryInterface $categoryRepository,
        public readonly Escaper $escaper,
    ) {}

// rest of code

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for checking this PR. This code is indeed quite old now. I will consider updating it if I ever get a feedback from the repo owner : p (@avstudnitz)

@rubenromao rubenromao Mar 12, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Well done btw!
Hope that this is approved and merged soon.

adexandros pushed a commit to adexandros/AvS_ScopeHint2 that referenced this pull request Jul 13, 2026
Plugs Magento\Catalog\Model\Category\DataProvider::afterGetMeta to inject
store-view override tooltips for non-global category EAV attributes,
mirroring the existing product-form behaviour.

New files:
- Service/EavScopeOverrideDetector — loads category per store view via
  CategoryRepository, memoises per request, resolves select option labels,
  enforces configurable store-count kill-switch (dev/debug/scopehint_max_stores).
- Plugin/CategoryDataProviderPlugin — afterGetMeta plugin that iterates
  non-global attributes and injects tooltip.description via ArrayManager.
- Test/Unit/Service/EavScopeOverrideDetectorTest — fully-mocked unit tests
  covering no-override, single override, skip-current-store, kill-switch,
  missing category (NoSuchEntityException), and select-label resolution.

Modified files:
- etc/adminhtml/di.xml — registers the new plugin.
- etc/adminhtml/system.xml — adds scopehint_max_stores field (group debug).
- etc/config.xml — sets default value of 50 for scopehint_max_stores.
- readme.md — documents the performance kill-switch.

Supersedes avstudnitz#27 — thanks @thedotwriter for the original approach.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants