Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule: Source models extending \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource must use $_options to cache values #63

Open
schmengler opened this issue Jan 4, 2019 · 0 comments

Comments

@schmengler
Copy link
Collaborator

Rule

The AbstractSource model contains a protected attribute $_options that is meant to cache the options. Unfortunately this is not enforced, instead each implementation of getAllOptions() is responsible to use that cache properly.

Reason

EAV source models often load possible values for attributes from external resources. Every access to those values, e.g. with $product->getAttributeText() calls getAllOptions() on the source model. The result of this method should only be calculated once.

Implementation

Any class that extends the abstract source model should return $this->_options in getAllOptions()

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

No branches or pull requests

1 participant