未发现(承诺)错误:product_categories.name不是检索的方面

时间:2019-06-23 02:44:47

标签: laravel vue.js algolia instantsearch.js vue-instant-search

我正在使用<ais-menu-select显示我的所有产品类别并基于该产品过滤产品。

但是我遇到了这个错误:Uncaught (in promise) Error: product_categories.name is not a retrieved facet.

我已经将product_categories.name字段添加到了信息中心的“方面”部分。

enter image description here

这是我的代码:

<template>
    <ais-instant-search
            :search-client="searchClient"
            index-name="products"
            class="relative">
        <ais-search-box>
            <div slot-scope="{ currentRefinement, isSearchStalled, refine }" class="m-0 flex">
                <!--                <span :hidden="!isSearchStalled">Loading...</span>-->
                <div class="relative w-full">
                    <input type="search"
                           class="w-full text-black p-2 border-l border-t border-b border-gray-300 text-base rounded-l"
                           placeholder="Enter a product name..."
                           v-model="currentRefinement"
                           @input="refine($event.currentTarget.value)">
                        <ais-state-results>
                            <p slot-scope="{ query, hits }" v-if="!hits.length" class="absolute top-100 z-50 bg-white text-black w-full p-2 border-4 border-blue border-t-0 max-h-450px overflow-y-auto">
Not found: <q>{{ query }}</q>
                            </p>
                            <template v-else slot-scope="{ query }">
                                <ais-hits v-if="query.length > 0" class="absolute top-100 z-50 bg-white text-black w-full p-2 border-4 border-blue border-t-0 max-h-450px overflow-y-auto">
                                    <template slot="item"
                                              slot-scope="{ item }"
                                    >
                                        <div class="w-full">
                                            <div class="flex flex-wrap mb-2">
                                                <div class="relative w-64px h-64px">
                                                    <a :href="getUrl(item)"
                                                       class="block w-64px h-64px">
                                                        <img :src="getFeaturedImage(item.media)" class="max-w-full h-auto mx-auto" :alt="item.name"/>
                                                    </a>
                                                </div>
                                                <div class="flex flex-1 flex-col ml-2">
                                                    <h3 class="mb-1 text-base ">
                                                        <a :href="getUrl(item)" class="block hover:text-blue cursor-pointer">
                                                            <ais-highlight
                                                                    :hit="item"
                                                                    attribute="name"
                                                            />
                                                        </a>
                                                    </h3>
                                                    <div>
                                                        <span class="text-blue text-base font-bold">{{ item.price | toCurrency }}</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </template>
                                </ais-hits>
                                <div v-else />
                            </template>
                        </ais-state-results>
                </div>
                <ais-menu-select attribute="product_categories.name" class="bg-white text-black">
                    <select slot-scope="{ items, canRefine, refine }"
                            :disabled="!canRefine"
                            @change="refine($event.currentTarget.value)"
                            class="text-black border-0 h-full"
                    >
                        <option value="">All Categories</option>
                        <option
                                v-for="item in items"
                                :key="item.value"
                                :value="item.value"
                                :selected="item.isRefined"
                        >
                            {{ item.label }} ({{ item.count }})
                        </option>
                    </select>
                </ais-menu-select>

                <button class="btn btn-gray rounded-l-none px-4">Search</button>
            </div>
        </ais-search-box>
    </ais-instant-search>
</template>

0 个答案:

没有答案