Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit adb300c

Browse files
authored
Merge pull request #104 from DivanteLtd/develop
v1.3.1
2 parents f607ca9 + 1c4e9ae commit adb300c

File tree

91 files changed

+14161
-8096
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+14161
-8096
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ dist/
44
npm-debug.log
55
.vscode/
66
.idea/
7-
yarn.lock
87
api_start.sh
98
api_test.sh
109
package-lock.json

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ Executing `docker exec -it vue-storefront-api_app_1 yarn install` will also down
9393

9494
NOTE: `npm` users will still have to install the dependencies individually in their modules.
9595

96+
## Reviews
97+
To use review feature you need to install custom module for Magento 2: [Divante ReviewApi](https://github.com/DivanteLtd/magento2-review-api)
98+
9699
License
97100
-------
98101

config/default.json

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"server": {
33
"host": "localhost",
4-
"port": 8080
4+
"port": 8080,
5+
"searchEngine": "elasticsearch"
56
},
67
"elasticsearch": {
78
"host": "localhost",
@@ -12,6 +13,13 @@
1213
"vue_storefront_catalog",
1314
"vue_storefront_catalog_de",
1415
"vue_storefront_catalog_it"
16+
],
17+
"indexTypes": [
18+
"product",
19+
"category",
20+
"cms",
21+
"attribute",
22+
"taxrule"
1523
]
1624
},
1725
"redis": {
@@ -44,7 +52,7 @@
4452
"defaultCountry": "DE",
4553
"defaultRegion": "",
4654
"calculateServerSide": true,
47-
"sourcePriceIncludesTax": false
55+
"sourcePriceIncludesTax": false
4856
},
4957
"i18n": {
5058
"fullCountryName": "Germany",
@@ -71,7 +79,7 @@
7179
"defaultCountry": "IT",
7280
"defaultRegion": "",
7381
"calculateServerSide": true,
74-
"sourcePriceIncludesTax": false
82+
"sourcePriceIncludesTax": false
7583
},
7684
"i18n": {
7785
"fullCountryName": "Italy",
@@ -155,5 +163,38 @@
155163
"maxDownloadCacheSize": 1000,
156164
"tmpPathRoot": "/tmp",
157165
"debug": false
166+
},
167+
"entities": {
168+
"category": {
169+
"includeFields": [ "children_data", "id", "children_count", "sku", "name", "is_active", "parent_id", "level", "url_key" ]
170+
},
171+
"attribute": {
172+
"includeFields": [ "attribute_code", "id", "entity_type_id", "options", "default_value", "is_user_defined", "frontend_label", "attribute_id", "default_frontend_label", "is_visible_on_front", "is_visible", "is_comparable" ]
173+
},
174+
"productList": {
175+
"sort": "",
176+
"includeFields": [ "type_id", "sku", "product_links", "tax_class_id", "special_price", "special_to_date", "special_from_date", "name", "price", "priceInclTax", "originalPriceInclTax", "originalPrice", "specialPriceInclTax", "id", "image", "sale", "new", "url_key" ],
177+
"excludeFields": [ "configurable_children", "description", "configurable_options", "sgn" ]
178+
},
179+
"productListWithChildren": {
180+
"includeFields": [ "type_id", "sku", "name", "tax_class_id", "special_price", "special_to_date", "special_from_date", "price", "priceInclTax", "originalPriceInclTax", "originalPrice", "specialPriceInclTax", "id", "image", "sale", "new", "configurable_children.image", "configurable_children.sku", "configurable_children.price", "configurable_children.special_price", "configurable_children.priceInclTax", "configurable_children.specialPriceInclTax", "configurable_children.originalPrice", "configurable_children.originalPriceInclTax", "configurable_children.color", "configurable_children.size", "product_links", "url_key"],
181+
"excludeFields": [ "description", "sgn"]
182+
},
183+
"product": {
184+
"excludeFields": [ "updated_at", "created_at", "attribute_set_id", "status", "visibility", "tier_prices", "options_container", "msrp_display_actual_price_type", "has_options", "stock.manage_stock", "stock.use_config_min_qty", "stock.use_config_notify_stock_qty", "stock.stock_id", "stock.use_config_backorders", "stock.use_config_enable_qty_inc", "stock.enable_qty_increments", "stock.use_config_manage_stock", "stock.use_config_min_sale_qty", "stock.notify_stock_qty", "stock.use_config_max_sale_qty", "stock.use_config_max_sale_qty", "stock.qty_increments", "small_image"],
185+
"includeFields": null,
186+
"filterFieldMapping": {
187+
"category.name": "category.name.keyword"
188+
}
189+
}
190+
},
191+
"usePriceTiers": false,
192+
"boost": {
193+
"name": 3,
194+
"category.name": 1,
195+
"short_description": 1,
196+
"description": 1,
197+
"sku": 1,
198+
"configurable_children.sku": 1
158199
}
159200
}

doc/2. graphQl support.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Introduction
2+
3+
Vue storefront now supports using graphQl as an alternative API endpoint to get data for products, categories, products, and taxerules.
4+
For now Graphql uses resolver what fetch data from Elasticsearch. But potentialy can have different resolvers working with different Search Engines / 3rd Party APIs
5+
6+
## GraphQl Schema
7+
8+
Graphql request to this API have to match query schema defined
9+
For product it is
10+
11+
```graphql
12+
type Query {
13+
products (
14+
search: String @doc(description: "Performs a full-text search using the specified key words."),
15+
filter: ProductFilterInput @doc(description: "Identifies which product attributes to search for and return."),
16+
pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once. This attribute is optional."),
17+
currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1."),
18+
sort: ProductSortInput @doc(description: "Specifies which attribute to sort on, and whether to return the results in ascending or descending order.")
19+
): Products
20+
}
21+
```
22+
23+
which has result of type Products
24+
25+
```graphql
26+
27+
type Products @doc(description: "The Products object is the top-level object returned in a product search") {
28+
items: JSON @doc(description: "An array of products that match the specified search criteria")
29+
page_info: SearchResultPageInfo @doc(description: "An object that includes the page_info and currentPage values specified in the query")
30+
total_count: Int @doc(description: "The number of products returned")
31+
aggregations: JSON @doc(description: "Layered navigation filters array as aggregations")
32+
sort_fields: SortFields @doc(description: "An object that includes the default sort field and all available sort fields")
33+
}
34+
```
35+
36+
and uses defined resolver
37+
```js
38+
const resolver = {
39+
Query: {
40+
products: (_, { search, filter, sort, currentPage, pageSize }, context, rootValue) =>
41+
list(filter, sort, currentPage, pageSize, search, context, rootValue)
42+
}
43+
}
44+
```
45+
46+
For other entity types you can check schemas and resolvers in the /src/graphql/elasticsearch correspond subfolder
47+
48+
49+
## Example request
50+
51+
Below is an example request for product
52+
53+
```graphql
54+
{
55+
products(search: "bag", filter: {
56+
status: {
57+
in: [0, 1], scope: "default"
58+
},
59+
stock: {
60+
is_in_stock: {eq: true, scope: "default"}
61+
},
62+
visibility: {
63+
in: [3, 4], scope: "default"}
64+
},
65+
sort: {
66+
updated_at: DESC
67+
}
68+
) {
69+
items
70+
total_count
71+
aggregations
72+
sort_fields {
73+
options {
74+
value
75+
}
76+
}
77+
page_info {
78+
page_size
79+
current_page
80+
}
81+
}
82+
}
83+
84+
85+
```
86+
87+
To see all available product filter options please check ProductFilterInput type in the graphQl product schema
88+
89+

docker-compose.nodejs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2.0'
1+
version: '3.0'
22
services:
33
app:
44
# image: divante/vue-storefront-api:latest
@@ -13,6 +13,7 @@ services:
1313
VS_ENV: dev
1414
volumes:
1515
- './config:/var/www/config'
16+
- './ecosystem.json:/var/www/ecosystem.json'
1617
- './migrations:/var/www/migrations'
1718
- './package.json:/var/www/package.json'
1819
- './scripts:/var/www/scripts'

docker-compose.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
version: '2.0'
1+
version: '3'
22
services:
33
es1:
4-
# image: divante/vue-storefront-elasticsearch:5.6.9
4+
container_name: elasticsearch
55
build: docker/elasticsearch/
6-
container_name: es1
7-
env_file: docker/elasticsearch/default.env
86
volumes:
7+
- ./docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
98
- 'esdat1:/usr/share/elasticsearch/data'
10-
networks:
11-
default:
12-
aliases:
13-
- elasticsearch
149
ports:
1510
- '9200:9200'
16-
ulimits:
17-
memlock:
18-
soft: -1
19-
hard: -1
11+
- '9300:9300'
12+
environment:
13+
ES_JAVA_OPTS: "-Xmx512m -Xms512m"
14+
2015
kibana:
21-
# image: divante/vue-storefront-kibana:5.6.9
2216
build: docker/kibana/
23-
env_file: docker/kibana/default.env
17+
volumes:
18+
- ./docker/kibana/config/:/usr/share/kibana/config:ro
2419
ports:
2520
- '5601:5601'
21+
depends_on:
22+
- es1
23+
2624
redis:
2725
image: 'redis:4-alpine'
2826
ports:
2927
- '6379:6379'
28+
3029
volumes:
3130
esdat1:

docker/elasticsearch/Dockerfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
FROM docker.elastic.co/elasticsearch/elasticsearch:5.6.9
1+
FROM docker.elastic.co/elasticsearch/elasticsearch:5.6.11
22

33
RUN bin/elasticsearch-plugin remove x-pack --purge
44

55
# Add your elasticsearch plugins setup here
66
# Example: RUN elasticsearch-plugin install analysis-icu
7-
8-
USER root
9-
10-
COPY wrapper.sh /usr/local/bin/
11-
12-
CMD ["wrapper.sh"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
## Default Elasticsearch configuration from elasticsearch-docker.
3+
## from https://github.com/elastic/elasticsearch-docker/blob/master/build/elasticsearch/elasticsearch.yml
4+
#
5+
cluster.name: "docker-cluster"
6+
network.host: 0.0.0.0
7+
8+
# minimum_master_nodes need to be explicitly set when bound on a public IP
9+
# set to 1 to allow single node clusters
10+
# Details: https://github.com/elastic/elasticsearch/pull/17288
11+
discovery.zen.minimum_master_nodes: 1
12+
13+
## Use single node discovery in order to disable production mode and avoid bootstrap checks
14+
## see https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html
15+
#
16+
discovery.type: single-node

docker/elasticsearch/default.env

Lines changed: 0 additions & 3 deletions
This file was deleted.

docker/elasticsearch/wrapper.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)