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

Slowness when getting field's value #36

Open
wei2go opened this issue Jun 15, 2020 · 0 comments
Open

Slowness when getting field's value #36

wei2go opened this issue Jun 15, 2020 · 0 comments

Comments

@wei2go
Copy link

wei2go commented Jun 15, 2020

  • I have a section (e.g. items) of entries with a MultiSelect type dynamic field (e.g. myDynamicField).
  • This section has about 250 entries
  • I have a PHP loop like this:
$items = craft\elements\Entry::find()->section('items')->limit(null)->all();
// this loop takes ages
foreach ($items as $item) {
    // ...
    $val = $item->myDynamicField; // by toggling this line, it makes about 50 seconds difference.
    // ...
}

I realized by running this code block, it takes ages. As mentioned above, I narrowed it down by toggling the line of code to query the dynamic field's value, and found out it makes about 50 seconds difference.

Then I looked into the normalizeValue() function of your lewisjenkins\craftdynamicfields\fields\Multiselect, and found out it tries to render the options template, which I have some entry queries there to generate. You might need it for something else, but in this case (when we just try to access the field data like $item->myDynamicField), is there a way that we can just get the value stored in the database without running rendering the options?

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