Git Product home page Git Product logo

Comments (10)

riasvdv avatar riasvdv commented on June 18, 2024

Are you sure you're using the correct section handle and that they're all published?

from craft-scout.

larsboldt avatar larsboldt commented on June 18, 2024

Yes, this code gives me all articles for the same section:
{% set entries = craft.entries.section('cityPlanningArticles').all() %}

from craft-scout.

riasvdv avatar riasvdv commented on June 18, 2024

I cannot seem to reproduce this, it must be something with the section you defined, could you post a screenshot of the section settings and the content? Maybe I can find something wrong with them then.

from craft-scout.

larsboldt avatar larsboldt commented on June 18, 2024

skjermbilde 2018-03-20 kl 12 06 39

What content do you mean?

from craft-scout.

riasvdv avatar riasvdv commented on June 18, 2024

I've just tried everything with the same settings and it works for me.

Does this return something when you try it from a module or plugin?

\craft\elements\Entry::find()->section('cityPlanningArticles')->all(); this is what Scout runs in the background to find the entries.

from craft-scout.

larsboldt avatar larsboldt commented on June 18, 2024

It does.

from craft-scout.

larsboldt avatar larsboldt commented on June 18, 2024

This is the query... returns zero elements.

(
    [editable] => 
    [sectionId] => Array
        (
            [0] => 1
        )

    [typeId] => 
    [authorId] => 
    [authorGroupId] => 
    [postDate] => 
    [before] => 
    [after] => 
    [expiryDate] => 
    [defaultOrderBy:protected] => Array
        (
            [entries.postDate] => 3
        )

    [elementType] => craft\elements\Entry
    [query] => 
    [subQuery] => 
    [contentTable] => {{%content}}
    [customFields] => 
    [inReverse] => 
    [asArray] => 
    [id] => 
    [uid] => 
    [fixedOrder] => 
    [status] => Array
        (
            [0] => live
        )

    [archived] => 
    [dateCreated] => 
    [dateUpdated] => 
    [siteId] => 
    [enabledForSite] => 1
    [relatedTo] => 
    [title] => 
    [slug] => 
    [uri] => 
    [search] => 
    [ref] => 
    [with] => 
    [orderBy] => 
    [withStructure] => 1
    [structureId] => 
    [level] => 
    [ancestorOf] => 
    [ancestorDist] => 
    [descendantOf] => 
    [descendantDist] => 
    [siblingOf] => 
    [prevSiblingOf] => 
    [nextSiblingOf] => 
    [positionedBefore] => 
    [positionedAfter] => 
    [_result:craft\elements\db\ElementQuery:private] => 
    [_resultCriteria:craft\elements\db\ElementQuery:private] => 
    [_searchScores:craft\elements\db\ElementQuery:private] => 
    [select] => Array
        (
            [0] => **
        )

    [selectOption] => 
    [distinct] => 
    [from] => 
    [groupBy] => 
    [join] => 
    [having] => 
    [union] => 
    [params] => Array
        (
        )

    [queryCacheDuration] => 
    [queryCacheDependency] => 
    [_events:yii\base\Component:private] => Array
        (
        )

    [_eventWildcards:yii\base\Component:private] => Array
        (
        )

    [_behaviors:yii\base\Component:private] => Array
        (
            [customFields] => craft\behaviors\ElementQueryBehavior Object
                (
                    [altText] => 
                    [article] => 
                    [articleFeedbackEmail] => 
                    [attribution] => 
                    [description] => 
                    [files] => 
                    [filteredMatrixContent] => 
                    [flowContent] => 
                    [image] => 
                    [images] => 
                    [imageText] => 
                    [linkText] => 
                    [linkUrl] => 
                    [logo] => 
                    [mainArticle] => 
                    [mainImages] => 
                    [mainQuote] => 
                    [matrixContent] => 
                    [month01] => 
                    [month02] => 
                    [month03] => 
                    [month04] => 
                    [month05] => 
                    [month06] => 
                    [month07] => 
                    [month08] => 
                    [month09] => 
                    [month10] => 
                    [month11] => 
                    [month12] => 
                    [pageTitle] => 
                    [prioritized] => 
                    [projectTitle] => 
                    [quote] => 
                    [quoteArticle] => 
                    [relatedServices] => 
                    [richTextField] => 
                    [seo] => 
                    [snippet] => 
                    [source] => 
                    [subLogoTextFirst] => 
                    [subLogoTextSecond] => 
                    [summary] => 
                    [tagBusiness] => 
                    [tagEditorial] => 
                    [tagSubject] => 
                    [targetMethodNew] => 
                    [targetText] => 
                    [targetUrl] => 
                    [text] => 
                    [textAuthor] => 
                    [textForMainPage] => 
                    [textTitle] => 
                    [transcription] => 
                    [urlForMainPage] => 
                    [vimeoLink] => 
                    [_customFieldValues:craft\behaviors\ContentBehavior:private] => Array
                        (
                        )

                    [owner] => craft\elements\db\EntryQuery Object
 *RECURSION*
                )

        )

    [where] => 
    [limit] => 
    [offset] => 
    [indexBy] => 
    [emulateExecution] => 
)

from craft-scout.

riasvdv avatar riasvdv commented on June 18, 2024

The only filter on there is sectionId => 1 and status => live, I have no idea why it wouldn't return anything.

from craft-scout.

larsboldt avatar larsboldt commented on June 18, 2024

We are running a multi-site setup, and siteId 4 is the main site, but not where the articles of section "cityPlanningArticles" are located. Those are located in siteId 1 in our case... siteId must be determined by which site is enabled for a section I guess and that might not be whats happening here? If multiple sites are enabled for a section they should all be listed in the where part of the query?

Debugging the queryBuilder I found this:

                        (
                            [0] => and
                            [1] => Array
                                (
                                    [0] => or
                                    [1] => Array
                                        (
                                            [0] => =
                                            [1] => entries.sectionId
                                            [2] => 1
                                        )

                                )

                            [2] => Array
                                (
                                    [elements_sites.siteId] => 4
                                )

                            [3] => Array
                                (
                                    [content.siteId] => 4
                                )

from craft-scout.

riasvdv avatar riasvdv commented on June 18, 2024

@larsboldt Ah, that makes sense, I think most use cases would call for seperate indexes for each site, so you could do the following in your mappings:

[
    'indexName' => 'poc_magasin_1',
    'elementType' => \craft\elements\Entry::class,
    'criteria' => [
        'section' => 'cityPlanningArticles',
        'siteId' => 1
    ],
    'transformer' => function (craft\base\Element $element) {
        return $element->toArray();
    },
],
[
    'indexName' => 'poc_magasin_2',
    'elementType' => \craft\elements\Entry::class,
    'criteria' => [
        'section' => 'cityPlanningArticles',
        'siteId' => 2
    ],
    'transformer' => function (craft\base\Element $element) {
        return $element->toArray();
    },
],
...

from craft-scout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.