Giter Club home page Giter Club logo

vue-storefront-api's Introduction

REST API backend for vue-storefront

Stay connected

GitHub Repo stars Twitter Follow YouTube Channel Subscribers Discord

This is a backend service for vue-storefront. Provides data access to product catalog (via ElasticSearch) and allows users to place orders into order queue (by default it's Redis queue supported via kqueue library).

Vue Storefront

Vue Storefront is a standalone PWA (Progressive Web Application ) storefront for your eCommerce, possible to connect with any eCommerce backend (eg. Magento, Prestashop or Shopware) through the API.

Vue Storefront is and always will be in the open source. Anyone can use and support the project, we want it to be a tool for the improvement of the shopping experience. The project is still in the prove of concept phase. We are looking for Contributors and Designer willing to help us the the solution development.

Vue Storefront was build as a all-in-one front-end for eCommerce. For providing the best performance we decided to use Vue.js as a front-end library, Node.js + Express (and maybe GraphQL support) as a server-API, Elastic Search as a database of products and full PWA/off-line support. Here you can read more about the proof of concept for Vue Storefront connected with Magento2.

Besides a big improvement for the shopping experience, we also want to create a great code base for every developer who needs to work on a front-end application for the eCommerce.

Requirements

  • Docker and Docker Compose

Already included in vue-storefront-api Docker image (required locally, if you do not use containerization):

  • Node.js 10.x or higher
  • Yarn

Installation

Start a containerized environment

The legacy (A) mode - starting just the Elastic and Redis containers: docker-compose up -d

The standard (B) mode - starting Elastic, Redis + Vue Storefront API containers: docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml up -d

As a result, all necessary services will be launched:

  • Vue Storefront API runtime environment (Node.js with dependencies from package.json)
  • ElasticSearch
  • Redis
  • Kibana (optional)

Import product catalog

Product catalog is imported using elasticdump, which is installed automatically via project dependency. The default ElasticSearch index name is: vue_storefront_catalog

  • (A) yarn restore
  • (B) docker exec -it vuestorefrontapi_app_1 yarn restore

Then, to update the structures in the database to the latest version (data migrations), do the following:

  • (A) yarn migrate
  • (B) docker exec -it vuestorefrontapi_app_1 yarn migrate

By default, the application server is started in development mode. It means that code auto reload is enabled along with ESLint, babel support.

It restores JSON documents stored in ./var/catalog.json. The opposite command - used to generate catalog.json file from running ElasticSearch cluster:

  • (A) yarn dump
  • (B) docker exec -it vuestorefrontapi_app_1 yarn dump

Access ElasticSearch data with Kibana

A Kibana service is available to explore, search and visualize indexed data at the following url:

http://localhost:5601/

At first access it will ask to specify an index pattern, insert vue_storefront*

Note: Kibana is not provided with the Elastic 7 docker file. Please install it on your own when needed or check the es-head Chrome plugin.

Elastic 7 support

By default, Vue Storefront API docker files and config are based on Elastic 5.6. We plan to change the default Elastic version to 7 with the 1.11 stable release. As for now, the Elastic 7 support is marked as experimental.

How to use it?

In order to use the new Elastic 7 please make sure your vue-storefront-api has been checked out from the PR#342 branch. To start the Elastic 7 docker service please use the docker-compose.elastic7.yml file provided:

docker-compose -f docker-compose.elastic7.yml up

Then, please do change the config/local.json to start using the new Elastic API. Key properties in the elasticsearch section are: indexTypes and apiVersion (to be set to 7.1). If you're using the multistore configuration please make sure you adjusted the storeViews.*.elasticsearch section as well - per each separate store.

  "elasticsearch": {
    "host": "localhost",
    "index": "vue_storefront_catalog",
    "port": 9200,
    "protocol": "http",
    "min_score": 0.01,
    "indices": [
      "vue_storefront_catalog",
      "vue_storefront_catalog_de",
      "vue_storefront_catalog_it"
    ],
    "indexTypes": [
      "product",
      "category",
      "cms_block",
      "cms_page",
      "attribute",
      "taxrule",
      "review"
    ],
    "apiVersion": "7.1"
  }

Starting from Elasitc 6 and 7 we can have just single document type per single index. Vue Storefront used to have product, category ... types defined in the vue_storefront_catalog.

From now on, we're using the separate indexes per each entity type. The convention is: ${indexName}_${entityType}. If your' logical index name is vue_storefront_catalog then it will be mapped to the physical indexes of: vue_storefront_catalog_product, vue_storefront_catalog_category ...

Tools are adjusted to ES7. You can use yarn db new, yarn restore, yarn mage2vs import. Just make sure that you have set up config.elasticsearch.apiVersion to 7.1.

API access

Catalog API calls are compliant with ElasticSearch (it works like a filtering proxy to ES). More on ES queries: ElasticSearch queries tutorial

Elastic search endpoint: http://localhost:8080/api/catalog/search/<INDEX_NAME>/. You can run the following command to check if everything is up and runing (it assumes vue_storefront_catalog as default index name):

curl -i http://elastic:changeme@localhost:8080/api/catalog/vue_storefront_catalog/_search

Data formats

This backend is using ElasticSearch data formats popularized by ElasticSuite for Magento2 by Smile.fr.

Data migrations

Please use data migration mechanism provided to manipulate Redis, ElasticSearch or kue. Details: https://github.com/DivanteLtd/vue-storefront-api/tree/master/doc

Adding custom modules with own dependencies (Yarn only)

When adding custom Extensions to the API you might want to define some dependencies inside them. Thanks to Yarn workspaces dependencies defined inside your custom module will be installed when you execute yarn at project root level, so it's way easier and faster than installing all modules dependencies separately.

To do this, define the package.json with your dependencies in your custom module:

  • src/api/extensions/{your-custom-extension}/package.json
  • src/platforms/{your-custom-platform}/package.json

Executing docker exec -it vue-storefrontapiapp_1 yarn install will also download your custom modules dependencies.

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

Reviews

To use review feature you need to install custom module for Magento 2: Divante ReviewApi By default new reviews will be added with status "Pending".

  "review": {
    "defaultReviewStatus": 2 
  },

Output Cache

Vue Storefront API supports output cache for catalog operations. Cache is tagged and can by dynamically invalidated. Please find the details how to configure it in our docs.

You can manually clear the Redis cache for specific tags by running the following command:

npm run cache clear
npm run cache clear -- --tag=product,category
npm run cache clear -- --tag=P198
npm run cache clear -- --tag=*

Running initial Magento2 import

Magento2 data import is now integrated into vue-storefront-api for simplicity. It's still managed by the mage2vuestorefront - added as a dependency to vue-storefront-api.

After setting the config.magento2.api section using Yours Magento2 oauth credentials:

  "magento2": {
    "imgUrl": "http://localhost:8080/media/catalog/product",
    "assetPath": "/../var/magento2-sample-data/pub/media",
    "api": {
      "url": "http://demo-magento2.vuestorefront.io/rest",
      "consumerKey": "byv3730rhoulpopcq64don8ukb8lf2gq",
      "consumerSecret": "u9q4fcobv7vfx9td80oupa6uhexc27rb",
      "accessToken": "040xx3qy7s0j28o3q0exrfop579cy20m",
      "accessTokenSecret": "7qunl3p505rubmr7u1ijt7odyialnih9"
    }
  },

You can run the following command to execute the full import:

 yarn mage2vs import

... or in multistore setup You can run the same command with specified store-code parameter

 yarn mage2vs import --store-code=de

Import of CMS blocks and pages is also performed by the full import. If the CMS API extension ((SnowdogApps/magento2-cms-api)[https://github.com/SnowdogApps/magento2-cms-api]) was not installed in magento 2, it's recommended to skip the CMS import commands.

 yarn mage2vs import --skip-blocks --skip-pages

Executing delta indexer

You can use the following command to run a delta indexer for a specific storeview:

yarn mage2vs productsdelta --store-code=de

Self signed certificates

Often in non production environment other services are using self signed certificates for secure connection. You can easily setup the application to trust them by putting them in config/certs directory.

License

MIT

vue-storefront-api's People

Contributors

akbarkz avatar alinadivante avatar andrzejewsky avatar anqaka avatar bloodf avatar cewald avatar cyclonecode avatar davidrouyer avatar didkan avatar dimasch avatar fifciu avatar flyingmana avatar gopkumargopi avatar haelbichalex avatar hunterjamesio avatar igloczek avatar lnicorena avatar lukeromanowicz avatar mdesmet avatar mkoszutowski avatar patzick avatar pkarw avatar proxiblue avatar rain2o avatar resubaka avatar sesze avatar thermscissorpunch avatar tjitse-e avatar vladimirplastovets avatar yuriboyko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-storefront-api's Issues

app ignores config, queries localhost

Just tried to run the app with docker:
docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app yarn mage2vs import

Elasticsearch ERROR: 2018-12-24T12:13:06Z
  Error: Request error, retrying
  POST http://localhost:9200/vue_storefront_catalog_eur/category/2/_update => connect ECONNREFUSED 127.0.0.1:9200
      at Log.error (/var/www/node_modules/elasticsearch/src/lib/log.js:226:56)
      at checkRespForFailure (/var/www/node_modules/elasticsearch/src/lib/transport.js:259:18)
      at HttpConnector.<anonymous> (/var/www/node_modules/elasticsearch/src/lib/connectors/http.js:163:7)
      at ClientRequest.wrapper (/var/www/node_modules/lodash/lodash.js:4935:19)
      at emitOne (events.js:116:13)
      at ClientRequest.emit (events.js:211:7)
      at Socket.socketErrorListener (_http_client.js:401:9)
      at emitOne (events.js:116:13)
      at Socket.emit (events.js:211:7)
      at emitErrorNT (internal/streams/destroy.js:66:8)

However, localhost is not what I have given in my config before I started the app. There's http://172.24.0.8:9200 in there and I can confirm there's correct ES on that IP with
docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app curl http://172.24.0.8:9200.

I would expect the app to query what was given in config, but that's not the case. Why?

Request to have yarn workspaces in package.json

Request to define below in package.json

"workspaces": [
    "src/api/extenstions/*"
    "src/platform/*"
]

Yarn users could make use of this feature when they want to keep their sub-modules in extensions and platform separate.

Elasticsearch not active before searching for product

Categories in menu are not showing on first pageload.

It appears to me that elasticsearch is not active or it's being "activated" when you search for product "test" on https://techdrones.no.

After clicking on the product in search, and clicking on "go back button", you'll see the categories finally appearing in the menu.

On my other 2 projects https://logima.io and https://hoversport.no everything works fine and all projects have the same configuration and different indexes etc.

What could be the cause?

Default image URL wrong running against bitnami/magento-docker

the default image base url in default.json is:
https://magento.example.com/media/catalog/product

while my Magento docker application only responds to images at:
https://magento.example.com/pub/media/catalog/product

is my configuration wrong? is this something that has changed by default in Magento?

Issues with reindexing after mage2vs

Hey!

Not sure an issue was the best way to get some help here, but I'm unsure if this is a case of me doing something or that there is actually an issue.

I left mage2vs running overnight and whilst looking at ElasticSearch (Kibana) & Redis I could see data was in fact being populated - great!

Came to it this morning and instead of the 58,000 products that should have been there the data set has reduced to 868 - it was on at least 10,000 when I left it. This leads me to believe the imported data has actually been deleted by the rebuild process.

I pulled some errors out of the console, hopefully this gives some indication of what might have gone wrong? Can someone explain the rebuild process and if there is any risk of data loss? If so, how do I go about writing a pull request to ensure data isn't lost?

If I am understanding the process correctly in my head, can we dump the elastic search data into a local temp file prior to rebuild so it can be restored and a rebuild re-attempted without the need to run a 58,000 product import again if rebuild fails.

Thanks!

Public index alias does not exists [aliases_not_found_exception] aliases [vue_storefront_catalog_1544150754] missing, with { resource.type="aliases" & resource.id="vue_storefront_catalog_1544150754" }
"** Putting the mappings on top of vue_storefront_catalog_1544150754"
"** We will reindex vue_storefront_catalog with the current schema"
{
  "took":1794,
  "timed_out":false,
  "total":58180,
  "updated":0,
  "created":996,
  "deleted":0,
  "batches":1,
  "version_conflicts":0,
  "noops":0,
  "retries":{
    "bulk":0,
    "search":0
  },
  "throttled_millis":0,
  "requests_per_second":-1.0,
  "throttled_until_millis":0,
  "failures":[
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"445",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    },
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"311",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    },
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"524",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    },
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"580",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    }
  ]
}
{
  "took":1794,
  "timed_out":false,
  "total":58180,
  "updated":0,
  "created":996,
  "deleted":0,
  "batches":1,
  "version_conflicts":0,
  "noops":0,
  "retries":{
    "bulk":0,
    "search":0
  },
  "throttled_millis":0,
  "requests_per_second":-1.0,
  "throttled_until_millis":0,
  "failures":[
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"445",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    },
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"311",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    },
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"524",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    },
    {
      "index":"vue_storefront_catalog_1544150754",
      "type":"product",
      "id":"580",
      "cause":{
        "type":"illegal_argument_exception",
        "reason":"mapper [configurable_children.special_price] of different type, current_type [float], merged_type [text]"
      },
      "status":400
    }
  ]
}
Public index alias does not exists [index_not_found_exception] no such index, with { resource.type="index_or_alias" & resource.id="vue_storefront_catalog" & index_uuid="na" & index="vue_storefront_catalog" }

Check product stock - 500 (Internal Server Error)

Scenario:

Click on add to cart button:

2017-12-11_10-08-34

Mon, 11 Dec 2017 06:05:49 GMT express deprecated req.param(name): Use req.params, req.body, or req.query instead at src/api/stock.js:39:12
Mon, 11 Dec 2017 06:05:49 GMT express deprecated req.param(name): Use req.params, req.body, or req.query instead at src/api/stock.js:41:24
debug: Calling API endpoint: GET http://m.local/V1/stockItems/MS11-XS-Blue
debug: url=http://m.local/V1/stockItems/MS11-XS-Blue, method=GET, Authorization=OAuth oauth_consumer_key="uq9yhhs6c9qs4pi19fip2c189sedpxha", oauth_nonce="bSoMCDFWdWMnV3ukWax2c9JXQ9mYyMnO", oauth_signature="xtNapmnrU6kj1geuYwpPQuoMKUM%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1512972349", oauth_token="jxbi2dfacjt2xvjpbvnw71gb891oqwn3", oauth_version="1.0", json=true, body=undefined
debugGET /api/stock/check/MS11-XS-Blue : Response received.
500 812.110 ms - 44
error: API call failed: HTTP ERROR undefined

See incorrect endpoint
http://m.local/V1/stockItems/MS11-XS-Blue

Should be:
http://m.local/rest/V1/stockItems/MS11-XS-Blue

API definition for platform abstraction

Is there something more precise available as an API definition to plug a different backend Platform?

There is an abstract implementation but since JS is dynamic it does not provide any explicit or implicit clue on the expected data models, response models, error behavior etc.
https://github.com/DivanteLtd/vue-storefront-api/tree/master/src/platform/abstract

Since it seems to be a 1:1 proxy of the extenal API an OpenAPI or similar definition would suffice, too (maybe even better since it would allow to build a compatible server side implementation that uses a lighter stack without an extra elasticsearch, redis etc (all of which is only necessary for backend platforms that are too bad to tackle the actual load in a stable way).

Problem with send data by order create

Hello!
I have a problem - when sending an order in the o2m logs i see an error after sending the request to the endpoint "shipping information".
error: API call failed: Please specify shipping method. 2018-04-02T11:48:47.557Z - error: Error placing an order Please specify shipping method. string
But all need information sending:
debug: Calling API endpoint: POST http://*****************/shipping-information token: info: url=**********************/shipping-information, method=POST, Authorization=Bearer *********, **shippingMethodCode=dpdcarrier, shippingCarrierCode=dpdcarrier**, extensionAttributes=undefined
o2m tries to send the order five times, after each time this error.
But the most interesting thing is this: if I take the same data, the same endpoint, send the request via postman, and then resume sending the same order through o2m, it will go without problems.
What can it be? What is the problem?

No products found!

I’ve been trying to sync data from magneto (CE version 2.3) to VS (release 1.7.0) and for some reasons the Products are not showing up on the screen

Categories are visible in the UI but not Products

I’ve tried both the “Fast integration” and “Manual integration” described in @ [(https://docs.vuestorefront.io/guide/installation/magento.html#integrating-magento2-with-your-local-instance)]

I did not get any errors and checking my ES, I get see that “category” and “product” are in ES
curl -XPOST 'localhost:9200/vue_storefront_catalog/category/_search'
curl -XPOST 'localhost:9200/vue_storefront_catalog/product/_search'

Any pointers as to why the Products are not showing up when I click on the appropriate Category in VS frontend. BTW, It works ok on the default Magento frontend. Ruled out product setup issue in Magento

curl -XPOST 'localhost:9200/vue_storefront_catalog/product/_search'

{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":4,"max_score":1.0,"hits":[{"_index":"vue_storefront_catalog_1548591100","_type":"product","_id":"12","_score":1.0,"_source":{"id":12,"sku":"cavendish_banana","name":"Cavendish Banana","attribute_set_id":4,"price":20,"status":1,"visibility":4,"type_id":"simple","created_at":"2019-01-25 18:26:53","updated_at":"2019-01-27 13:16:58","extension_attributes":{"website_ids":[1],"category_links":[{"category_id":"7","position":10}]},"product_links":[],"options":[],"media_gallery_entries":[{"types":["image","small_image","thumbnail","swatch_image"],"file":"/c/a/cavendish_bananas.jpeg","media_type":"image","disabled":false,"id":5,"label":null,"position":1}],"tier_prices":[],"custom_attributes":null,"final_price":20,"max_price":20,"max_regular_price":20,"minimal_regular_price":20,"special_price":null,"minimal_price":20,"regular_price":20,"image":"/c/a/cavendish_bananas.jpeg","small_image":"/c/a/cavendish_bananas.jpeg","thumbnail":"/c/a/cavendish_bananas.jpeg","swatch_image":"/c/a/cavendish_bananas.jpeg","options_container":"container2","url_key":"cavendish-banana","gift_message_available":"2","required_options":"0","has_options":"0","meta_title":"Cavendish Banana","meta_keyword":"Cavendish Banana","meta_description":"Cavendish Banana This one is good 1","tax_class_id":"0","category_ids":["7"],"description":"<p>This one is good 1</p>","short_description":"<p>This one is good 2</p>","country_of_manufacture":"SC","size":"4","links":{},"stock":{"item_id":20,"product_id":12,"stock_id":1,"qty":0,"is_in_stock":false,"is_qty_decimal":false,"show_default_notification_message":false,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":1,"min_sale_qty":1,"use_config_max_sale_qty":true,"max_sale_qty":10000,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":1,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":false,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":"2019-01-27 13:16:58","is_decimal_divided":false,"stock_status_changed_auto":1},"media_gallery":[{"image":"/c/a/cavendish_bananas.jpeg","pos":1,"typ":"image","lab":null}],"category":[{"category_id":7,"name":"Bananas"}],"tsk":1548623855015}},{"_index":"vue_storefront_catalog_1548591100","_type":"product","_id":"15","_score":1.0,"_source":{"id":15,"sku":"danvers_carrots_jojo","name":"Danvers Carrots","attribute_set_id":4,"price":12,"status":1,"visibility":4,"type_id":"simple","created_at":"2019-01-27 11:29:36","updated_at":"2019-01-27 11:43:40","extension_attributes":{"website_ids":[1],"category_links":[{"category_id":"9","position":0}]},"product_links":[],"options":[],"media_gallery_entries":[],"tier_prices":[],"custom_attributes":null,"final_price":12,"max_price":12,"max_regular_price":12,"minimal_regular_price":12,"special_price":null,"minimal_price":12,"regular_price":12,"options_container":"container2","url_key":"danvers-carrots","gift_message_available":"2","required_options":"0","has_options":"0","meta_title":"Danvers Carrots","meta_keyword":"Danvers Carrots","meta_description":"Danvers Carrots ","tax_class_id":"0","category_ids":["9"],"links":{},"stock":{"item_id":23,"product_id":15,"stock_id":1,"qty":0,"is_in_stock":false,"is_qty_decimal":false,"show_default_notification_message":false,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":1,"min_sale_qty":1,"use_config_max_sale_qty":true,"max_sale_qty":10000,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":1,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":false,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":"2019-01-27 11:43:40","is_decimal_divided":false,"stock_status_changed_auto":1},"media_gallery":[],"category":[{"category_id":9,"name":"Carrots"}],"tsk":1548623855015}},{"_index":"vue_storefront_catalog_1548591100","_type":"product","_id":"16","_score":1.0,"_source":{"id":16,"sku":"Simple Banana","name":"Simple Banana","attribute_set_id":4,"price":121,"status":1,"visibility":4,"type_id":"simple","created_at":"2019-01-27 20:40:40","updated_at":"2019-01-27 20:41:02","extension_attributes":{"website_ids":[1],"category_links":[{"category_id":"7","position":0}]},"product_links":[],"options":[],"media_gallery_entries":[],"tier_prices":[],"custom_attributes":null,"options_container":"container2","url_key":"simple-banana","gift_message_available":"2","required_options":"0","has_options":"0","meta_title":"Simple Banana","meta_keyword":"Simple Banana","meta_description":"Simple Banana ","tax_class_id":"0","category_ids":["7"],"country_of_manufacture":"SC","size":"4","links":{},"stock":{"item_id":24,"product_id":16,"stock_id":1,"qty":0,"is_in_stock":false,"is_qty_decimal":false,"show_default_notification_message":false,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":1,"min_sale_qty":1,"use_config_max_sale_qty":true,"max_sale_qty":10000,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":1,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":false,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":"2019-01-27 20:41:02","is_decimal_divided":false,"stock_status_changed_auto":1},"media_gallery":[],"category":[{"category_id":7,"name":"Bananas"}],"tsk":1548623855015}},{"_index":"vue_storefront_catalog_1548591100","_type":"product","_id":"13","_score":1.0,"_source":{"id":13,"sku":"burro_banana","name":"Burro Banana","attribute_set_id":4,"price":10,"status":1,"visibility":4,"type_id":"simple","created_at":"2019-01-25 18:39:33","updated_at":"2019-01-27 11:42:41","extension_attributes":{"website_ids":[1],"category_links":[{"category_id":"7","position":0}]},"product_links":[],"options":[],"media_gallery_entries":[{"types":["image","small_image","thumbnail","swatch_image"],"file":"/b/u/burro_bananas-1.jpg","media_type":"image","disabled":false,"id":6,"label":null,"position":1}],"tier_prices":[],"custom_attributes":null,"final_price":10,"max_price":10,"max_regular_price":10,"minimal_regular_price":10,"special_price":null,"minimal_price":10,"regular_price":10,"image":"/b/u/burro_bananas-1.jpg","small_image":"/b/u/burro_bananas-1.jpg","thumbnail":"/b/u/burro_bananas-1.jpg","swatch_image":"/b/u/burro_bananas-1.jpg","options_container":"container2","url_key":"burro-banana","gift_message_available":"2","required_options":"0","has_options":"0","meta_title":"Burro Banana","meta_keyword":"Burro Banana","meta_description":"Burro Banana ddddddd","tax_class_id":"0","category_ids":["7"],"description":"<p>ddddddd</p>","short_description":"<p>eeeeeeeeeeee</p>","links":{},"stock":{"item_id":21,"product_id":13,"stock_id":1,"qty":0,"is_in_stock":false,"is_qty_decimal":false,"show_default_notification_message":false,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":1,"min_sale_qty":1,"use_config_max_sale_qty":true,"max_sale_qty":10000,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":1,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":false,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":"2019-01-27 11:42:41","is_decimal_divided":false,"stock_status_changed_auto":1},"media_gallery":[{"image":"/b/u/burro_bananas-1.jpg","pos":1,"typ":"image","lab":null}],"category":[{"category_id":7,"name":"Bananas"}],"tsk":1548623855015}}]}} vagrant@vuestorefront:~/storefront-api$

Unable to run seo.js Script - Unexpected token import

Hi guys,

i'm encountering a problem running seo script to generate redirects from old magento url structure to new vs.

This is the output from console

$ node scripts/seo.js
/home/www/malianta/vue-storefront-api/scripts/seo.js:1
(function (exports, require, module, __filename, __dirname) { import CommandRouter from 'command-router'
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
error Command failed with exit code 1.

Does anyone faced the same issue?

Elastic Search Forces HTTP

Hey,

Been working on getting this into production for some proper testing (looks great locally, good work!).

So we've set up our AWS VPC alongside ElastiCache (Redis), EC2 for Node and Elasticsearch.

Unfortunately it seems we can't configure HTTPS for ElasticSearch requests which is somewhat hindering us as this is how AWS serves it.

I've tried modifying the ES client calls (such as src/graphql/elasticsearch/client.js) and adding a protocol option from config.json without any luck sadly.

const client = new elasticsearch.Client({
  hosts: [
    config.elasticsearch.protocol + '://' + config.elasticsearch.host + ':' + config.elasticsearch.port
  ]
});
  "elasticsearch": {
    "host": "<elastic>.amazonaws.com",
    "protocol": "https",
    "port": 9200,
    "indices": [
      "vue_storefront_catalog"
    ]
  },

screen shot 2018-09-13 at 17 23 21

Any pointers?

Thanks again.

ImageMagick requirement

The documentation nor yarn warns of a dependency of ImageMagick.

if ImageMagick is not installed on the server or host, images cannot be resized.

Add delta indexer to mage2vs

Since the mage2vs already has support for doing a full reindex it would also be really nice if it could handle productsdelta indexer. For instance:

program
  .command('productsdelta')
  .option('--store-code <storeCode>', 'storeCode in multistore setup', null)
  .action((cmd) => {
    const apiConfig = multiStoreConfig(config.magento2.api, cmd.storeCode)
    let magentoConfig = {
      TIME_TO_EXIT: 2000,
      PRODUCTS_SPECIAL_PRICES: true,
      MAGENTO_CONSUMER_KEY: apiConfig.consumerKey,
      MAGENTO_CONSUMER_SECRET: apiConfig.consumerSecret,
      MAGENTO_ACCESS_TOKEN: apiConfig.accessToken,
      MAGENTO_ACCESS_TOKEN_SECRET: apiConfig.accessTokenSecret,
      MAGENTO_STORE_ID: 1,
      INDEX_META_PATH: '.lastIndex.json',
      MAGENTO_URL: apiConfig.url,
      REDIS_HOST: config.redis.host,
      REDIS_PORT: config.redis.port,
      INDEX_NAME: config.elasticsearch.indices[0]

    }
    if (cmd.storeCode) {
      const storeView = config.storeViews[cmd.storeCode]
      if (!storeView) {
        console.error('Wrong storeCode provided - no such store in the config.storeViews[storeCode]', cmd.storeCode)
        process.exit(-1)
      } else {
        magentoConfig.INDEX_NAME = storeView.elasticsearch.index
        magentoConfig.INDEX_META_PATH = '.lastIndex-' + cmd.storeCode + '.json'
        magentoConfig.MAGENTO_STORE_ID = storeView.storeId
      }
    }

    const env = Object.assign({}, magentoConfig, process.env)  // use process env as well
    console.log('=== Delta indexer is about to start ===')

    exec('node', [
      '--harmony',
      'node_modules/mage2vuestorefront/src/cli.js',
      'productsdelta'
    ], { env: env, shell: true }).then((res) => {

    })

  })

Product API returns prices for root store only

Since 1.6 there's an issue in the product API, where only root store prices are return by the render-list API request.

File:

/src/api/product.ts

In the line

productProxy.renderList(req.query.skus.split(','), req.query.currencyCode, req.query.storeId && parseInt(req.query.storeId) > 0 || 1).then(

The third parameter passed to renderList is converted to a boolean

req.query.storeId && parseInt(req.query.storeId) > 0 || 1

This causes prices for all stores to the those of the root store.

It should be the storeId, to get correct prices and other store specific data. The following will correct this:

(req.query.storeId && parseInt(req.query.storeId) > 0) ? req.query.storeId : 1

Directory path to /media needs to be configurable

The media path is currently hard coded

Current implementation

~/vue-storefront-api/src/index.js

app.use('/media', express.static(__dirname + '/../var/magento2-sample-data/pub/media'))

~/vue-storefront-api/src/api/img.js

  const imgUrl = config.magento2.imgUrl + '/' + urlParts.slice(4).join('/')//.split('/'); // full original image url

Proposal

~/vue-storefront-api/src/index.js

app.use('/media', express.static(__dirname + config[config.platform].assetPath))

~/vue-storefront-api/src/api/img.js

  const imgUrl = config[config.platform].imgUrl + '/' + urlParts.slice(4).join('/')//.split('/'); // full original image url

_~/vue-storefront-api/config/default.json_
"magento2": {
	"url": "http://magento2.demo-1.xyz.com",
	"imgUrl": "http://localhost:8080/media/catalog/product",
	"assetPath": "/../var/magento2-sample-data/pub/media",
	"magentoUserName": "",
	"magentoUserPassword": "",
	"httpUserName": "",
	"httpUserPassword": "",
	"api": {
		"url": "http://demo-magento2.vuestorefront.io/rest",
		"consumerKey": "byv3730rhoulpopcq64don8ukb8lf2gq",
		"consumerSecret": "u9q4fcobv7vfx9td80oupa6uhexc27rb",
		"accessToken": "040xx3qy7s0j28o3q0exrfop579cy20m",
		"accessTokenSecret": "7qunl3p505rubmr7u1ijt7odyialnih9"
	}
}

Refactor migrate / install scripts to keep up to SRP

eko@eko-GE62VR-6RF:~/Schreibtisch/vue-storefront-api$ npm run migrate

> [email protected] migrate /home/eko/Schreibtisch/vue-storefront-api
> node node_modules/migrate/bin/migrate

Elasticsearch INFO: 2018-03-05T20:07:01Z
  Adding connection to http://localhost:9200/

  up : 1513603161654-reindex.js
Elasticsearch DEBUG: 2018-03-05T20:07:01Z
  starting request {
    "method": "POST",
    "path": "/_reindex",
    "body": {
      "source": {
        "index": "vue_storefront_catalog_temp"
      },
      "dest": {
        "index": "vue_storefront_catalog"
      }
    },
    "query": {}
  }
  

Elasticsearch DEBUG: 2018-03-05T20:07:01Z
  Request complete

{ Error: [index_not_found_exception] no such index, with { resource.type="index_or_alias" & resource.id="vue_storefront_catalog_temp" & index_uuid="_na_" & index="vue_storefront_catalog_temp" }
    at respond (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/src/lib/transport.js:307:15)
    at checkRespForFailure (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/src/lib/transport.js:266:7)
    at HttpConnector.<anonymous> (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/src/lib/connectors/http.js:159:7)
    at IncomingMessage.bound (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/node_modules/lodash/dist/lodash.js:729:21)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1055:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  status: 404,
  displayName: 'NotFound',
  message: '[index_not_found_exception] no such index, with { resource.type="index_or_alias" & resource.id="vue_storefront_catalog_temp" & index_uuid="_na_" & index="vue_storefront_catalog_temp" }',
  path: '/_reindex',
  query: {},
  body: 
   { error: 
      { root_cause: [Array],
        type: 'index_not_found_exception',
        reason: 'no such index',
        'resource.type': 'index_or_alias',
        'resource.id': 'vue_storefront_catalog_temp',
        index_uuid: '_na_',
        index: 'vue_storefront_catalog_temp' },
     status: 404 },
  statusCode: 404,
  response: '{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"vue_storefront_catalog_temp","index_uuid":"_na_","index":"vue_storefront_catalog_temp"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"vue_storefront_catalog_temp","index_uuid":"_na_","index":"vue_storefront_catalog_temp"},"status":404}',
  toString: [Function],
  toJSON: [Function] }
  error : [index_not_found_exception] no such index, with { resource.type="index_or_alias" & resource.id="vue_storefront_catalog_temp" & index_uuid="_na_" & index="vue_storefront_catalog_temp" } :: {"path":"/_reindex","query":{},"body":"{\"source\":{\"index\":\"vue_storefront_catalog_temp\"},\"dest\":{\"index\":\"vue_storefront_catalog\"}}","statusCode":404,"response":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"vue_storefront_catalog_temp\",\"index_uuid\":\"_na_\",\"index\":\"vue_storefront_catalog_temp\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"vue_storefront_catalog_temp\",\"index_uuid\":\"_na_\",\"index\":\"vue_storefront_catalog_temp\"},\"status\":404}"}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] migrate: `node node_modules/m

Example configuration clarification

Hi,

seems there is a little bit of mess in configuration file default.json under storeViews property:

{
  "storeViews": {
    "multistore": true,
    "mapStoreUrlsFor": [
      "de",
      "it"
    ],
    "de": {
      "storeCode": "de",
      "disabled": true,
      "storeId": 3,
      "name": "German Store",
      "url": "/de",
      "elasticsearch": {
        "host": "localhost:8080/api/catalog", <-----
        "index": "vue_storefront_catalog_de"
       },

what does elasticsearch.host refer to? seems not a elasticsearch path, and port is different from root elasticsearch property:

{
  "server": {
    "host": "localhost",
    "port": 8080
  },
  "elasticsearch": {
    "host": "localhost", <-----
    "port": 9200, <-----
    "user": "elastic",
    "password": "changeme",
    "indices": [
      "vue_storefront_catalog",
      "vue_storefront_catalog_de",
      "vue_storefront_catalog_it"
    ]
},

how storeViews.de.elasticsearch.host configuration is used?

error: uncaughtException: Specified query type "Query" not found in document.

Hi, i'm trying to deploy vue-storefront in cloud environment (docker+kubernetes). I succeeded to deploy a workin example but after changes broking it, even turning back to the previous state doesnt resolve the problem.

First I launch elasticsearch+redis. At this point they are up and running. Elastic search gives this warning
but i dont remember if it was there also before:

[2018-10-01T15:12:28,214][WARN ][o.e.d.c.x.s.AbstractXContentParser] Expected a boolean [true/false] for property [has_options] but got [0]

Then i launch api (an image) which runs following commands:

yarn install
yarn build
node dist/index.js

At this point, (even if i dont make restore, migrate and database import with mage2vs, elastic search is already populated from previous database import) api should be running.

Vue-storefront-api starts to listen on 0.0.0.0:8080 but it gives me error:

Extension mailchimp-subscribe registered under /ext/mailchimp-subscribe base URL
info: Winston logging library initialized.
Extension example-magento-api registered under /ext/example-magento-api base URL
Extension cms-data registered under /ext/cms-data base URL
error: uncaughtException: Specified query type "Query" not found in document. date=Mon Oct 01 2018 20:19:52 GMT+0000 (UTC), pid=1, uid=0, gid=0, cwd=/var/www, execPath=/usr/local/bin/node, version=v8.12.0, argv=[/usr/local/bin/node, /var/www/dist/index.js], rss=64294912, heapTotal=40284160, heapUsed=29084960, external=839586, loadavg=[0.603515625, 0.349609375, 0.365234375], uptime=6922854, trace=[column=17, file=/var/www/node_modules/graphql/utilities/buildASTSchema.js, function=null, line=133, method=null, native=false, column=null, file=null, function=Array.forEach, line=null, method=forEach, native=false, column=30, file=/var/www/node_modules/graphql/utilities/buildASTSchema.js, function=Object.buildASTSchema, line=126, method=buildASTSchema, native=false, column=28, file=/var/www/node_modules/graphql-tools/dist/schemaGenerator.js, function=buildSchemaFromTypeDefinitions, line=126, method=null, native=false, column=18, file=/var/www/node_modules/graphql-tools/dist/schemaGenerator.js, function=_generateSchema, line=49, method=null, native=false, column=20, file=/var/www/node_modules/graphql-tools/dist/schemaGenerator.js, function=makeExecutableSchema, line=62, method=null, native=false, column=53, file=/var/www/dist/index.js, function=null, line=96, method=null, native=false, column=30, file=module.js, function=Module._compile, line=653, method=_compile, native=false, column=10, file=module.js, function=Module._extensions..js, line=664, method=.js, native=false, column=32, file=module.js, function=Module.load, line=566, method=load, native=false], stack=[Error: Specified query type "Query" not found in document., at /var/www/node_modules/graphql/utilities/buildASTSchema.js:133:17, at Array.forEach (), at Object.buildASTSchema (/var/www/node_modules/graphql/utilities/buildASTSchema.js:126:30), at buildSchemaFromTypeDefinitions (/var/www/node_modules/graphql-tools/dist/schemaGenerator.js:126:28), at _generateSchema (/var/www/node_modules/graphql-tools/dist/schemaGenerator.js:49:18), at makeExecutableSchema (/var/www/node_modules/graphql-tools/dist/schemaGenerator.js:62:20), at Object. (/var/www/dist/index.js:96:53), at Module._compile (module.js:653:30), at Object.Module._extensions..js (module.js:664:10), at Module.load (module.js:566:32)]
Vue Storefront API started at http://0.0.0.0:8080

And then keeps logging this elastic search debug:

No additional data adapter for category
Entering HmacProcessor::process
POST /api/catalog/vue_storefront_catalog/category/_search?size=4000&from=0&sort=position%3Aasc&_source_include=children_data%2Cid%2Cchildren_count%2Csku%2Cname%2Cis_active%2Cparent_id%2Clevel%2Curl_key%2Cproduct_count 200 219.815 ms - 38095
Entering ProductProcessor::process
Taxes will be calculated for PL false
Elasticsearch INFO: 2018-10-01T20:19:55Z
Adding connection to http://elasticsearch:9200/

Elasticsearch
DEBUG: 2018-10-01T20:19:55Z
starting request {
"method": "POST",
"path": "/vue_storefront_catalog/taxrule/_search",
"body": {},
"query": {}
}

Elasticsearch
DEBUG: 2018-10-01T20:19:55Z
Request complete

Tax rate VAT23-PL = 23% found for PL /
Tax rate VAT23-PL = 23% found for PL /
Tax rate VAT23-PL = 23% found for PL /
Tax rate VAT23-PL = 23% found for PL /
Tax rate VAT23-PL = 23% found for PL /
Tax rate VAT23-PL = 23% found for PL /
Tax rate VAT23-PL = 23% found for PL /
Tax rate VAT23-PL = 23% found for PL /

I cant really get what causes the problem, so if you can take a look and give some feedback, it would be great. Thanks.

error : Error: Missing migration file: 1506760343216-example-products.js

Hi, someone know how fix it?

5 info lifecycle [email protected]~premigrate: [email protected]
6 info lifecycle [email protected]~migrate: [email protected]
7 verbose lifecycle [email protected]~migrate: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~migrate: PATH: /home/rbt/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/-/u/io/src/storefront/vue-storefront-api/node_modules/.bin:/home/rbt/.nvm/versions/node/v8.9.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
9 verbose lifecycle [email protected]~migrate: CWD: /mnt/-/u/io/src/storefront/vue-storefront-api
10 silly lifecycle [email protected]~migrate: Args: [ '-c', 'node node_modules/migrate/bin/migrate' ]
11 silly lifecycle [email protected]~migrate: Returned: code: 1  signal: null
12 info lifecycle [email protected]~migrate: Failed to exec migrate script

Cart update error

Hello!
I am trying to add a product to the cart but I get error 500.
Request: curl -XPOST -H "Content-Type: application/json" --data '{"cartItem":{"sku":"Reel%20Frontal%208%20Rulemanes%207000","qty":1,"quoteId":"c2a9b2c17e35571610cdcc7ae5533b86"}}' http://localhost:8080/api/cart/update?token=aus912qjdik8bpy0y3vwi1v3bsmsbl8l&cartId=c2a9b2c17e35571610cdcc7ae5533b86

Response: {"code":500,"result":"Producto que desea agregar no está disponible."}

But the product exists because when I do
curl -XGET localhost:8080/api/stock/check?sku=Reel%20Frontal%208%20Rulemanes%207000
I get 200 response with qty > 0.

I am working with Magento 2.

Magento Version: 2.2.5
Node Version: 8.11.2
Commit SHA: 84011bf

Thanks!!

Docker version mismatch

When trying to follow installation instruction, I got an error:

ERROR: Version mismatch: file ./docker-compose.yml specifies version 2.0 but extension file ./docker-compose.nodejs.yml uses version 3.0

The issue is docker-compose.yml specified version as 2 and docker-compose.nodejs.yml specifies version as 3.0.

Invalid apiVersion "5.5" [products processor]

https://github.com/DivanteLtd/vue-storefront-api/blob/58a888852a42f731261508840f1e4aab713a50ed/package.json#L62

error: uncaughtException: Invalid apiVersion "5.5", expected a function or one of _default, 6.6, 6.5, 6.4, 6.3, 6.2, 6.1, 6.0, 5.6, 2.4, 1.7, 0.90, 6.7, 7.0, 7.x, master date=Fri Feb 08 2019 11:22:53 GMT+0400 (+04), pid=1365, uid=501, gid=20, cwd=/Users/dima/vsf/api, execPath=/usr/local/Cellar/node@8/8.15.0/bin/node, version=v8.15.0, argv=[node, /Users/dima/vsf/api/src, --presets, env,stage-0], rss=121856000, heapTotal=87474176, heapUsed=57530152, external=195671, loadavg=[2.3447265625, 2.6728515625, 2.9140625], uptime=1470328, trace=[column=13, file=/Users/dima/vsf/api/node_modules/elasticsearch/src/lib/utils.js, function=Object.utils.funcEnum, line=285, method=funcEnum, native=false, column=33, file=/Users/dima/vsf/api/node_modules/elasticsearch/src/lib/client.js

Related elastic/elasticsearch-js#765

For fix your can use without ^ in package.json
"elasticsearch": "15.2.0",
+ @filrak @pkarw

And don't forget mage2storefront https://github.com/DivanteLtd/mage2vuestorefront/blob/159e717de1ec069cb5ca9032b4118229c4d717a5/package.json#L16

Disable cache

Hi :)

How can you temporarily disable all caching (in Elastic Search/Redis). For testing purposes.

mage2vs: MAGENTO_STORE_ID is never defined

When running yarn mage2vs import my script ends up failing on this URL: https://foo.com/rest/V1/products-render-info?searchCriteria=&[....]&storeId=1&currencyCode=USD
The storeId and currencyCode comes from node_modules/mage2vuestorefront/src/config.js which can be overridden by process.env but that's never done in mage2vs.js and it falls back to these erroneous values.

My config:

"availableStores": [
  "se"
],
"storeViews": {
  "multistore": true,
  "mapStoreUrlsFor": [
    "se"
  ],
  "se": {
    "storeId": 9,
    "name": "Swedish Store",
    "url": "/",
    "elasticsearch": {
      "host": "localhost:8080/api/catalog",
      "index": "vue_storefront_catalog_se"
    },
    // etc

Debugging with VsCode

This is not an issue but a help needed topic.
I was trying to understand the code and develop it further. And like most people i am using VSCode by default for javascript development. But i couldn't make debug work for me with the whole bable thing.
Can anyone suggest me, how we can utilize vscode debugging if anyone has figured that out already.

Can't connect to redis server using standard mode

I'm trying to run an import from an M2 site using the vs2mage import command but I'm running into issues with the redis container.

Steps to replicate:

  1. Clone fresh copy of vue-storefront-api
  2. Copy config/default.json as config/local.json
  3. Change magento2 settings (url, api credentials, etc)
  4. Start docker containers docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml up -d
  5. Run import command docker exec -it vue-storefront-api_app_1 yarn mage2vs import

Expected result

It should finish importing entities to elasticsearch/redis without errors.

Actual result

It throws the following error:

error: uncaughtException: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 date=Sun Nov 11 2018 13:30:27 GMT+0000 (UTC), pid=393, uid=0, gid=0, cwd=/var/www, execPath=/usr/local/bin/node, version=v8.12.0, argv=[/usr/local/bin/node, /var/www/node_modules/mage2vuestorefront/src/cli.js, reviews], rss=65208320, heapTotal=41844736, heapUsed=26356432, external=193979, loadavg=[0.16162109375, 0.09423828125, 0.07861328125], uptime=13868, trace=[column=14, file=net.js, function=TCPConnectWrap.afterConnect [as oncomplete], line=1191, method=afterConnect [as oncomplete], native=false], stack=[Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379,     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)]

I think this is because the container is trying to find the redis host in its own localhost 127.0.0.1:6379, but it's not really there. Since the app container starts with the depends_on: - redis... option you can get the host using the redis hostname but when I change the redis host from "localhost" to "redis" in my local.json file it still tries to connect to localhost for some reason.

Using legacy mode works fine.

Can't start elasticsearch container

i can't start elasticsearch container after i check container log

standard_init_linux.go:195: exec user process caused "no such file or directory"

any idea for this problem ?

Doesnt pull a package while docker-compose up

vue-storefront-api# docker-compose up
Building kibana
Step 1/3 : FROM docker.elastic.co/kibana/kibana:5.6.9
5.6.9: Pulling from kibana/kibana
469cfcc7a4b3: Pull complete
dbf532e807c5: Pull complete
2fc6a7ee8a3a: Pull complete
aebda185619a: Pull complete
e71a1432017d: Pull complete
5d9b6f46e6f2: Pull complete
0fe8dbe6804f: Waiting

it kept waiting on this package even over night.

npm db new --indexName

The npm db new --indexName=<indexName> command never ends in case of success, since it is missing a process.exit(0) in scripts/db.js on line 68.

Magento configuration in default.json

There is a magento configuration part in default.json config, but in your documentation for production you don't talk about it at all. Neither in your medium post where you explain how to integrate it with magento. By default it points to/for example data set. One should modify this part or its there for just demo use?

"magento2": {
    "url": "http://magento2.demo-1.xyz.com",
    "imgUrl": "http://localhost:8080/media/catalog/product",
    "assetPath": "/../var/magento2-sample-data/pub/media",
    "magentoUserName": "",
    "magentoUserPassword": "",
    "httpUserName": "",
    "httpUserPassword": "",
    "api": {
      "url": "http://demo-magento2.vuestorefront.io/rest",
      "consumerKey": "byv3730rhoulpopcq64don8ukb8lf2gq",
      "consumerSecret": "u9q4fcobv7vfx9td80oupa6uhexc27rb",
      "accessToken": "040xx3qy7s0j28o3q0exrfop579cy20m",
      "accessTokenSecret": "7qunl3p505rubmr7u1ijt7odyialnih9"
    }
  },

Multiple errors in production mode

When changing "VS_ENV: dev" to "VS_ENV: prod" in docker-compose.nodejs.yml there are multiple errors when "docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml up" is executed.

First of all ecosystem.json is not found:

app_1     | [PM2] PM2 Successfully daemonized
app_1     | [PM2][ERROR] File ecosystem.json not found
app_1     | ┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬─────┬──────┬──────────┐
app_1     | │ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
app_1     | └──────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴─────┴──────┴──────────┘
app_1     |  Use "pm2 show <id|name>" to get more details about an app
app_1     | error Command failed with exit code 1.

You can mount ecosystem.json from the git root directory add in docker-compose.nodejs.yml like this:

    environment:
      VS_ENV: prod
    volumes:
      - './config:/var/www/config'
      - './migrations:/var/www/migrations'
      - './package.json:/var/www/package.json'
      - './scripts:/var/www/scripts'
      - './src:/var/www/src'
      - './var:/var/www/var'
      - './ecosystem.json:/var/www/ecosystem.json'

Then the output looks better but the container exits anyway:

app_1     | [PM2] PM2 Successfully daemonized
app_1     | [PM2][WARN] Applications api not running, starting...
app_1     | [PM2] App [api] launched (1 instances)
app_1     | ┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
app_1     | │ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
app_1     | ├──────────┼────┼──────┼─────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
app_1     | │ api      │ 0  │ fork │ 83  │ online │ 0       │ 0s     │ 2%  │ 23.0 MB   │ root │ disabled │
app_1     | └──────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
app_1     |  Use "pm2 show <id|name>" to get more details about an app
app_1     | Done in 3.59s.
...
vue-storefront-api_app_1 exited with code 0

Not sure what exactly wents wrong in production mode.

Import only Enabled Products

This is more of a feature request really, but I suggest that the default behavior only import Enabled products from Magento. I don't know what kind of impact this will have on VSF, but my basic understanding of it so leads me to believe importing disabled products is unnecessary and only increases the size of the Elastic Search index.

Most Magento shops I have worked on seem to have a constant cycle of products that are enabled/disabled based on needs, stock, seasons, etc... By filtering the disabled products out it can decrease the sync time and the index size.

Let me know your thoughts, and if you have any concerns with this approach.

Issue with getting started following readme

I am trying to work through the readme to get the API up and running.

In the Installation section I am using the command shown for the Standard (B) mode. I checked my containers with docker container ls --all and I see the kibana, es1 and redis containers all running but the vue-storefront-api_app_1 has exited recently (like a few seconds ago).

When I try to import the product catalog after yarn restore I use the docker exec -it vuestorefrontapi_app_1 yarn restore command but I get an error "no such container" I think that is because of a typo in the readme. So I tried the same command but with vue-storefront-api_app_1 but I get a different error saying that container is not running.

I am new to docker but from what I understand it means the container ran and exited and docker exec only works on running containers. I tried to start the container again with docker start and docker run but it always exits right away.

I also tried running docker start - vue-storefront-api_app_1 but I get standard_init_linux.go:207: exec user process caused "no such file or directory" I have the vue-storefront-api directory in my docker folder...

How do I go about addressing this issue?

Running Windows 10, docker (18.09.1) and using linux containers (I tried switching to Windows containers as well but I couldn't get I got errors when running docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml up -d so I switched back to linux containers)

TypeError: console.debug is not a function

Hello everybody,

I'm not entirely sure if I'm doing something wrong and that's why I'm getting the error... or there's an actual error in the code, hehe.

When running npm run dev in order to have the API running, I get the following error in the Terminal:

[Function: HmacProcessor]
/home/ec2-user/vue-storefront-api/src/processor/default.js:24
            console.debug('Entering HmacProcessor::process');
                    ^

TypeError: console.debug is not a function
    at HmacProcessor.process (/home/ec2-user/vue-storefront-api/src/processor/default.js:12:17)
    at Request._callback (/home/ec2-user/vue-storefront-api/src/api/catalog.js:54:23)
    at Request.self.callback (/home/ec2-user/vue-storefront-api/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/home/ec2-user/vue-storefront-api/node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/home/ec2-user/vue-storefront-api/node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:292:16)
[nodemon] app crashed - waiting for file changes before starting...

The problematic line in the code seems to be the console.debug() method as my understanding is that there is no debug() method for console in NodeJs

https://github.com/DivanteLtd/vue-storefront-api/blob/49c7bb17648baf8ef691d4957f53d5837bd99ff7/src/processor/default.js#L12

Is it correct to say that this line needs to be changed to console.log()?

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.