DivanteLtd / magento1-vsbridge

Run the Progressive Web App (PWA) on top of Magento 1.9. This is a Vue Storefront bridge for Magento 1.x. MIT License
https://vuestorefront.io
MIT License
57 stars 49 forks source link

Schema incompatible for latest VS/VSAPI #6

Closed phoenix-bjoern closed 6 years ago

phoenix-bjoern commented 6 years ago

The magento1-vsbridge generates a different schema compared to mage2vs. In result you can not retrieve products because the filter parameter for "is_in_stock" does not match. The same is maybe true for the categories.

Here an example: magento1-vsbridge uses a flat schema for products and is_in_stock is saved on the same level as all other attributes in ES. mage2vs however uses a nested object in ES and it looks like this:

          "stock" : {
            "item_id" : 9,
            "product_id" : 9,
            "stock_id" : 1,
            "qty" : 1000,
            "is_in_stock" : true,
            "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" : null,
            "is_decimal_divided" : false,
            "stock_status_changed_auto" : 0
          },

VS however generates the following query:

curl 'https://demo.vuestorefront.io/api/catalog/vue_storefront_catalog/product/_search?size=18&from=0&sort=' -H 'Accept: application/json' -H 'Content-Type: application/json' \ --data-binary '{"query":{"bool":{"must":[{"range":{"visibility":{"gte":3,"lte":4}}},{"range":{"status":{"gte":0,"lt":2}}},{"match":{"stock.is_in_stock":true}}]}}}'

So stock.is_in_stock doesn't match any product in Elasticsearch.

The schema definition os magento1-vsbridge, mage2vs, VS and VSAPI needs to be aligned. Otherwise one will always fall apart.

pkarw commented 6 years ago

You're right. The stock object is not being returned by magento1-vsridge; It should be. So this is to be fixed.

For now You can reconfigure vue-storefront by setting "listOutOfStockProducts": true,

phoenix-bjoern commented 6 years ago

@pkarw already did that but no products are returned on category browsing. So I guess there is a second issue with the category structure.

pkarw commented 6 years ago

I would guess: visibility or status field is causing the problem. The logic of filtering these fields has been introduced after magento1-vsbridge was published so probably it requires some round of trial and error

phoenix-bjoern commented 6 years ago

We'll align the schema with mage2vs this week.