|
143 | 143 | <a href="https://ecomsearch.docs.apiary.io/#reference/items" target="_blank">API reference</a>.</p><p>The <code>._ecom-el</code> element must also have the following attributes:</p><table><thead><tr><th style="text-align: center;">Attribute</th><th style="text-align: center;">Description</th></tr></thead><tbody><tr><td style="text-align: center;"><code>data-type</code></td><td style="text-align: center;">Equal to <code>items</code></td></tr><tr><td style="text-align: center;"><code>data-term</code></td><td style="text-align: center;">Searched keyword <em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-from</code></td><td style="text-align: center;">Results offset number <em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-size</code></td><td style="text-align: center;">Maximum number of results <em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-sort</code></td><td style="text-align: center;">Results ordering, one of <a href="#sort-items-search-result">these enumered values</a><em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-ids</code></td><td style="text-align: center;">Filter by specific products IDs separated by <code>,</code><em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-brands</code></td><td style="text-align: center;">Filter by list of brands IDs separated by <code>,</code><em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-categories</code></td><td style="text-align: center;">Filter by list of categories IDs separated by <code>,</code><em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-price-min</code></td><td style="text-align: center;">Filter by minimum price <em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-price-max</code></td><td style="text-align: center;">Filter by maximum price <em>(optional)</em></td></tr><tr><td style="text-align: center;"><code>data-spec-*</code></td><td style="text-align: center;">Filter by product specification <em>(optional)</em></td></tr></tbody></table><h4>Products list sample</h4><p>The example below is a simple implementation of a list of trending products,
|
144 | 144 | using <a href="https://vuejs.org/v2/guide/list.html" target="_blank">Vue list</a>:</p><pre><code class="language-html"><div class="row _ecom-el" data-type="items">
|
145 | 145 | <div class="col-md-2" v-for="item in body.hits.hits">
|
146 |
| - <div v-if="body = item._source" class="item"> |
147 |
| - <div v-if="body.pictures && body.pictures[0] && body.pictures[0].normal" class="item-img"> |
148 |
| - <img v-bind:src="body.pictures[0].normal.url" v-bind:alt="body.pictures[0].normal.alt" /> |
| 146 | + <div v-if="item = item._source" class="item"> |
| 147 | + <div v-if="item.pictures && item.pictures[0] && item.pictures[0].normal" class="item-img"> |
| 148 | + <img v-bind:src="item.pictures[0].normal.url" v-bind:alt="item.pictures[0].normal.alt" /> |
149 | 149 | </div>
|
150 |
| - <a v-bind:href="body.slug"> |
151 |
| - <h3> {{ name(body) }} </h3> |
| 150 | + <a v-bind:href="item.slug"> |
| 151 | + <h3> {{ name(item) }} </h3> |
152 | 152 | </a>
|
153 | 153 | <p class="price-block">
|
154 |
| - <span v-if="onPromotion(body)"> |
155 |
| - {{ body.currency_symbol }} |
156 |
| - <strong class="price"> {{ formatMoney(body.price) }} </strong> |
157 |
| - <span class="base-price"> {{ formatMoney(body.base_price) }} </span> |
| 154 | + <span v-if="onPromotion(item)"> |
| 155 | + {{ item.currency_symbol }} |
| 156 | + <strong class="price"> {{ formatMoney(item.price) }} </strong> |
| 157 | + <span class="base-price"> {{ formatMoney(item.base_price) }} </span> |
158 | 158 | </span>
|
159 | 159 | <span v-else>
|
160 |
| - {{ body.currency_symbol }} |
161 |
| - <strong class="price"> {{ formatMoney(price(body)) }} </strong> |
| 160 | + {{ item.currency_symbol }} |
| 161 | + <strong class="price"> {{ formatMoney(price(item)) }} </strong> |
162 | 162 | </span>
|
163 | 163 | </p>
|
164 |
| - <span v-if="body.available"> |
165 |
| - <button v-if="inStock()" class="buy"> Buy </button> |
| 164 | + <span v-if="item.available"> |
| 165 | + <button v-if="inStock(item)" class="buy"> Buy </button> |
166 | 166 | <span class="no-stock" v-else> Out of stock </span>
|
167 | 167 | </span>
|
168 | 168 | </div>
|
|
187 | 187 | </a>
|
188 | 188 | <ul>
|
189 | 189 | <li v-for="item in body.hits.hits">
|
190 |
| - <div v-if="body = item._source" class="item"> |
191 |
| - <div v-if="body.pictures && body.pictures[0] && body.pictures[0].normal" class="item-img"> |
192 |
| - <img v-bind:src="body.pictures[0].normal.url" v-bind:alt="body.pictures[0].normal.alt" /> |
| 190 | + <div v-if="item = item._source" class="item"> |
| 191 | + <div v-if="item.pictures && item.pictures[0] && item.pictures[0].normal" class="item-img"> |
| 192 | + <img v-bind:src="item.pictures[0].normal.url" v-bind:alt="item.pictures[0].normal.alt" /> |
193 | 193 | </div>
|
194 |
| - <a v-bind:href="body.slug"> |
195 |
| - <h4> {{ name(body) }} </h4> |
| 194 | + <a v-bind:href="item.slug"> |
| 195 | + <h4> {{ name(item) }} </h4> |
196 | 196 | </a>
|
197 |
| - <p> SKU: {{ body.sku }} </p> |
| 197 | + <p> SKU: {{ item.sku }} </p> |
198 | 198 | <p class="price-block">
|
199 |
| - <span v-if="onPromotion(body)"> |
200 |
| - {{ body.currency_symbol }} |
201 |
| - <strong class="price"> {{ formatMoney(body.price) }} </strong> |
202 |
| - <span class="base-price"> {{ formatMoney(body.base_price) }} </span> |
| 199 | + <span v-if="onPromotion(item)"> |
| 200 | + {{ item.currency_symbol }} |
| 201 | + <strong class="price"> {{ formatMoney(item.price) }} </strong> |
| 202 | + <span class="base-price"> {{ formatMoney(item.base_price) }} </span> |
203 | 203 | </span>
|
204 | 204 | <span v-else>
|
205 |
| - {{ body.currency_symbol }} |
206 |
| - <strong class="price"> {{ formatMoney(price(body)) }} </strong> |
| 205 | + {{ item.currency_symbol }} |
| 206 | + <strong class="price"> {{ formatMoney(price(item)) }} </strong> |
207 | 207 | </span>
|
208 | 208 | </p>
|
209 |
| - <button v-if="inStock()" class="buy"> Buy </button> |
| 209 | + <button v-if="inStock(item)" class="buy"> Buy </button> |
210 | 210 | <span class="no-stock" v-else> Out of stock </span>
|
211 | 211 | </div>
|
212 | 212 | </li>
|
|
0 commit comments