Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [eager-loading]

The tag has no usage guidance.

1
vote
1answer
16 views

Eager Loading Relatedto & Target Elements

I have quite a substantial amount of queries heading out for this bit of code below. I've tried quite a few things to get it down, but I need to eager load some things just to try and reduce the ...
1
vote
1answer
59 views

Eager loading on entry not reducing queries

Using this snippet returns me 38 queries on my homepage without the Eager Beaver plugin. {% do craft.app.elements.eagerLoadElements( className(entry), [entry], ['headerImage', 'image1', '...
1
vote
1answer
42 views

Eagerload inverse relation

I would like to eagerload inverse relation. Business case: I have stories, stories are connected to books over relatedBooks field. Now I would like to query those books only which not have any story. ...
1
vote
1answer
58 views

How to speed up a single entry page with Eager Loading

This is a single entry page. I have an assets field of imageGallery which allows multiple images to be uploaded but it could also be empty. I want to use the first image at the top of the page (if one ...
2
votes
1answer
91 views

Craft incredibly slow site performance

I am experiencing incredibly slow site performance. This extends to loading the control panel (/dashboard, /login). This only happens when I put the site on to my hosting, locally using MAMP it runs ...
0
votes
0answers
22 views

Paginating with offset and limit not working when there is 1 result more than first page - Optimise?

A complicated one to explain, so I'll jump straight in: {% set pageNumber = craft.request.getPageNum %} {% set firstPageLimit = 8 %} {% set defaultLimit = 9 %} {% set limit = pageNumber == 1 ? ...
0
votes
0answers
33 views

Include the asset's volume in the eager loading. [Element API]

On Element API, I'm eager loading the header image like: $criteria = [ 'section' => $section, 'with' => ['categories', 'header_image'] ]; But, in the output, I cannot get the volume ...
1
vote
1answer
24 views

Get the fields (fieldLayout) of the section. Not the entry

Can I get all the fields of a section? For example, I have channel events, I want the fields in that section, but not related to any specific event. I want to know all the fields (not the values), ...
1
vote
0answers
48 views

Eager Loading Entries - Creating a Navigation from a structure

I have a multi-level structure in Craft that is being used for navigation. As part of this I have a few different entry types, but each entry that links to a page has a entry-field of singlePage. At ...
1
vote
1answer
31 views

Correctly using eager loading in Plugin development

I'm trying to get some data with eager loading, which results in more queries than before. Is there another way to tune down the number of queries as low as possible? As you can see i only need the ...
1
vote
1answer
59 views

Eager loading fields within categories

Is it possible to eagerLoad fields in categories? I have this code; {% set markets = craft.categories.group({ section: 'markets', with: ['bannerImage'] }) %} which for some reason is throwing ...
1
vote
1answer
181 views

Eager-Loading Assets in Matrix

I've been using this example to eager load images, stored in an Assets field which is located in a Matrix field. My query looks like this: {% set entries = craft.entries.section('project') .with(['...
1
vote
1answer
50 views

How to get related entry data using ElementCriteriaModel in a plugin

I am working on a custom plugin which gets some entry data using $criteria = craft()->elements->getCriteria(ElementType::Entry); $criteria->order('postDate asc'); $criteria->dateUpdated = ...
1
vote
1answer
83 views

Eager load Imager transforms in Craft Commerce

I am using Imager to create my image transforms. I am on a category page and I want to list all of the products. I did a quick .with(['cf_shop_assets']) optimization and wanted to continue with the ...
2
votes
1answer
263 views

Eager-Loading child elements in a multi-level structure section

I have a structure that looks like this: Experiment ( Level 1) Cages (Level 2) Animals (Level 3) Measurement (Level 4) I am outputting this information into some inline JSON like so: {% set mice =...
2
votes
1answer
93 views

Combine Eager-Loading and relatedTo(category)

For a website I'm building for a client I've build a navigation where on hover an image changes dynamically to the image assigned to the entry. See this page for a better understanding: http://...
1
vote
1answer
73 views

Looping through an assets field type within a matrix field that's eager loaded

I'm trying to loop through images that are eager-loaded inside matrix block, but I can't get the images inside a matrix field handle to loop and show each individual image. The loop I have loops the ...
1
vote
1answer
49 views

Entry Count plugin performance / template optimisation

I'm using Ben Croker's Entry Count plugin in my News channel but have noticed a huge performance hit, I know its probably down to how I am loading the entries in to my template so I am looking for ...
1
vote
1answer
30 views

How do I eager load a dropdown field?

I'm going through my current project and making my loops more "eager". It's working great in several areas and improving performance massively but for some reason I can't get it to work when the ...
1
vote
1answer
75 views

Eager-loading of matrix field with getPage

Can anyone provide a working example to extend the following code (add support for matrix block named "copy") and allow getPage usage: {% set entries = craft.entries({ section: ['news'], order: ...
1
vote
2answers
156 views

Eager load a list of entries, then only the first asset, from the first block type

I would like to eager load: A list of entries Within the entries loop, the first image, from the first of a block type on a matrix field. Loading the entries like this {% set entries = craft....
1
vote
1answer
37 views

Starting & Ending Loops with Eager Loaded Elements

Basically, I have two sections of a page. In one section of the page, I want to output the first 8 entries in a loop. In the next section of a page, I want to output from the 9th entry to the end of ...
2
votes
1answer
60 views

Grouping a large number of entries

I have imported data with 18000+ entries. It's a list of product models with brands associated to each. The product model is being used as the title and the brand field is plain text. There are ...
3
votes
2answers
119 views

How to improve performance of this nested entries/array template?

I have an event calendar of sorts for music gigs. The back-end has sections for Artists and Venues, where I enter appropriate info, and another section, Shows, which I choose an artist, a venue, and ...
0
votes
0answers
47 views

Getting “do not have method or closure named” error when trying to eager load

Below is the full block of code I am working with. This is part of a template for showing all businesses that belong to a sub-category. I need to load all businesses related to the current category, ...
1
vote
0answers
54 views

Ordering entries based on an eager-loaded element's custom field

I have a query that loads a set of movies, and eager-loads corresponding shows, which are related elements. For now, the movies are sorted by startingDate, which is a custom field in the movie entry: ...
0
votes
0answers
69 views

Best way to improve complex query?

This question is related to a previous question I asked: Sort entries in a category via entry field I have a page that is running the same query from the previous question: {% set businesses = craft....
2
votes
2answers
139 views

Eager Loading breaking focus point

I’m trying to cut down the amount of database queries on the homepage of a site I’m working on, and am attempting to do some eager loading of an asset set in a supertable field. However, although the ...
3
votes
1answer
271 views

Craft 3: query matrixBlocks and eager load its owner?

Does anybody know if it's possible to load matrixBlock and eager load the entries (=owner) the matrixBlocks belong to in Craft 3? I tried: {% set blocks = craft.matrixBlocks.type('eventDate')....
1
vote
1answer
130 views

Enforce search match multiple parameters

I actually found this code on here Search Form with Craft Commerce. I had a problem with this code pulling up products that didn't match, and then after creating a new product it worked for a bit and ...
1
vote
0answers
111 views

Eager Loading Image Transforms In Plugin

The craft docs on eager loading show you how to eager load image transforms in twig. {% set entries = craft.entries({ with: [ ['coolImage', { withTransforms: ['transform'] }] ] }) %} ...
2
votes
1answer
154 views

Accessing Eager Loaded Transforms

The craft docs on eager loading show you how to eager load image transforms in twig. {% set entries = craft.entries({ with: [ ['coolImage', { withTransforms: ['transform'] }] ] }) %} ...
1
vote
0answers
283 views

Superslow loading of pages in Craft locally

I am having trouble pinpointing the issue but I am struggling with some of my pages taking an absolute age to load. For example; It might be a local MAMP issue, but some pages load fine and I ...
4
votes
0answers
96 views

Eagerloading Matrix fields resulting in empty array

I'm trying to eager-load a Matrix field with it's blocktype and related field types. For some reason the _eagerLoadedBlockTypeElements are empty arrays. If I get rid of the with clause on ...
0
votes
2answers
381 views

Trouble understanding eager loading

I've tried to apply eager loading per Craft's docs, but it doesn't seem to work. When I do this, will I have access to all the entry fields? If not, do I have to include all the fields I want in the ...
1
vote
2answers
428 views

Eager loading with conditions

I'm working on improving the performance of my website, and for some areas, I believe eager-loading will help. On each page of the site it's possible to bring out related entries at the bottom, but ...
2
votes
2answers
316 views

Using Focuspoint with eager loading

I'm using eager loading for retrieving some images for my gallery: {% set employments = craft.entries({ section: 'employments', with: ['photo] }) %} This works fine and I can see all images on my ...
0
votes
0answers
144 views

Eager Loading not reducing the queries

Related to this previous post. But I have created a new post with more information. Understanding Eager Loading So My template code with Eager Loading looks like this. {% set articles = craft....
2
votes
2answers
933 views

Understanding Eager Loading

I am trying to get to grips with Eager Loading. I have the following code: {% for article in entry.relatedArticles %} <div class="c-card // l-card--third"> <a href="{{ article.url }}">...
4
votes
1answer
438 views

Eager Loading a Structure and descendants

In looking at the the BaseElementModel:getDescendants() method and saw it checks for eager loading elements named 'descendants.' // Eager-loaded? if ($this->hasEagerLoadedElements('descendants')) {...
5
votes
1answer
549 views

Eager Load Matrix Field with Assets Field Type

I am trying to eager load an image asset assigned to a matrix. The template is pulling entries in from a section and each entry has the matrix field assigned to it that serves as an image gallery. ...
4
votes
2answers
384 views

Getting an array of ids from an array of eager-loaded elements within Twig

I have been using the ids() method on the ElementCriteriaModel returned by a call to an entries field within a Twig template to return an array of ids for further processing. Now I wish to eager-...
1
vote
2answers
488 views

Can I eager load Super Table fields in a Matrix block?

I have a Matrix with a Super Table in many of its blocks that I'm trying to eager load, but I can't figure out the syntax (or if its possible). The Super Table field's handle is columnSize and it ...
5
votes
1answer
693 views

Eager Loading Users Returning “Array to String Conversion” Error

I am trying to eager load users in a specific group to reduce queries. I've tried this: {% set designers = craft.users({ group: 'designers', ...
3
votes
1answer
531 views

Eager-load and pagination

I'm currently working on a relation-heavy website with a colleague of mine and, for that reason, eager-loading stuff looks very appealing to us. We've succeeded in eager-loading pretty much everything ...
1
vote
1answer
784 views

Eager loading EntryElementType from custom ElementType in a plugin

trying to get my head wrapped around eager loading element relationships in my plugin. A little context, I’m working on a navigation module and I have a Node element type, which belongs to a ...
3
votes
0answers
203 views

Assets Order Effected by Eager Loading [closed]

I am trying to eager load an asset field that contains 4 images. When I originally set my entries the order was not affected as written below: {% set products = craft.entries.section('products') %} ...
7
votes
1answer
615 views

Eager loading of reverse related elements?

Is it possible to load reverse related elements? I mean if the elements I’m querying are the target elements? Example: I’m setting up a criteria model to get some categories and I also want to load ...