vuestorefront / vue-storefront-api

Vue.js storefront for Magento2 (and not only) - data backend
https://www.vuestorefront.io
MIT License
348 stars 338 forks source link

Magneto 2.2.6 :Requested store is not found #331

Open insaurabh opened 5 years ago

insaurabh commented 5 years ago

I am trying to integrate with my Magento store.

Magento Version: 2.2.6 Node Version: 8.16 Yarn:1.17

In live Magento site, there is no store id 1. Currently, i have store id 2 and 3 only.

Still it hit &storeId=1&currencyCode=USD

I used cli vsf init

I didn't change anything in config/local.json.

http://localhost/magento232/rest/V1/products-render-info?searchCriteria=&searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=24-MB01%2C24-MB04%2C24-MB03%2C24-MB05%2C24-MB06%2C24-MB02%2C24-UB02%2C24-WB01%2C24-WB02%2C24-WB05%2C24-WB06%2C24-WB03%2C24-WB07%2C24-WB04%2C24-UG06%2C24-UG07%2C24-UG04%2C24-UG02%2C24-UG05%2C24-UG01%2C24-WG084%2C24-WG088%2C24-UG03%2C24-WG081-gray%2C24-WG081-pink%2C24-WG081-blue%2C24-WG082-gray%2C24-WG082-pink%2C24-WG082-blue%2C24-WG083-gray%2C24-WG083-pink%2C24-WG083-blue%2C24-WG085%2C24-WG086%2C24-WG087%2C24-MG04%2C24-MG01%2C24-MG03%2C24-MG05%2C24-MG02%2C24-WG09%2C24-WG01%2C24-WG03%2C24-WG02%2C24-WG085_Group%2C240-LV04%2C240-LV05%2C240-LV06%2C240-LV07%2C240-LV08&searchCriteria[filter_groups][0][filters][0][condition_type]=in&storeId=1&currencyCode=USD

My config file ( config/local.json)

{
  "server": {
    "host": "localhost",
    "port": 8080,
    "searchEngine": "elasticsearch"
  },
  "orders": {
    "useServerQueue": false
  },
  "catalog": {
    "excludeDisabledProducts": false
  },
  "elasticsearch": {
    "host": "localhost",
    "port": 9200,
    "protocol": "http",
    "user": "elastic",
    "password": "changeme",
    "min_score": 0.01,
    "indices": [
      "vue_storefront_catalog",
      "vue_storefront_catalog_de",
      "vue_storefront_catalog_it"
    ],
    "indexTypes": [
      "product",
      "category",
      "cms",
      "attribute",
      "taxrule",
      "review"
    ],
    "apiVersion": "5.6"
  },
  "redis": {
    "host": "localhost",
    "port": 6379,
    "db": 0,
    "auth": false
  },
  "kue": {},
  "availableStores": [
    "de",
    "it"
  ],
  "msi": {
    "enabled": false,
    "defaultStockId": 1
  },
  "storeViews": {
    "multistore": true,
    "mapStoreUrlsFor": [
      "de",
      "it"
    ],
    "de": {
      "storeCode": "de",
      "disabled": false,
      "storeId": 3,
      "name": "German Store",
      "url": "/de",
      "elasticsearch": {
        "host": "localhost:8080/api/catalog",
        "index": "vue_storefront_catalog_de"
      },
      "msi": {
        "stockId": 2
      },
      "tax": {
        "defaultCountry": "DE",
        "defaultRegion": "",
        "calculateServerSide": true,
        "sourcePriceIncludesTax": false
      },
      "i18n": {
        "fullCountryName": "Germany",
        "fullLanguageName": "German",
        "defaultLanguage": "DE",
        "defaultCountry": "DE",
        "defaultLocale": "de-DE",
        "currencyCode": "EUR",
        "currencySign": "EUR",
        "dateFormat": "HH:mm D-M-YYYY"
      }
    },
    "it": {
      "storeCode": "it",
      "disabled": false,
      "storeId": 4,
      "name": "Italian Store",
      "url": "/it",
      "elasticsearch": {
        "host": "localhost:8080/api/catalog",
        "index": "vue_storefront_catalog_it"
      },
      "msi": {
        "stockId": 2
      },
      "tax": {
        "defaultCountry": "IT",
        "defaultRegion": "",
        "calculateServerSide": true,
        "sourcePriceIncludesTax": false
      },
      "i18n": {
        "fullCountryName": "Italy",
        "fullLanguageName": "Italian",
        "defaultCountry": "IT",
        "defaultLanguage": "IT",
        "defaultLocale": "it-IT",
        "currencyCode": "EUR",
        "currencySign": "EUR",
        "dateFormat": "HH:mm D-M-YYYY"
      }
    }
  },
  "authHashSecret": "__SECRET_CHANGE_ME__",
  "objHashSecret": "__SECRET_CHANGE_ME__",
  "cart": {
    "setConfigurableProductOptions": false
  },
  "tax": {
    "defaultCountry": "PL",
    "defaultRegion": "",
    "calculateServerSide": true,
    "alwaysSyncPlatformPricesOver": false,
    "usePlatformTotals": true,
    "setConfigurableProductOptions": true,
    "sourcePriceIncludesTax": false
  },
  "bodyLimit": "100kb",
  "corsHeaders": [
    "Link"
  ],
  "platform": "magento2",
  "registeredExtensions": [
    "mailchimp-subscribe",
    "example-magento-api",
    "cms-data",
    "mail-service",
    "example-processor"
  ],
  "extensions": {
    "mailchimp": {
      "listId": "e06875a7e1",
      "apiKey": "a9a3318ea7d30f5c5596bd4a78ae0985-us3",
      "apiUrl": "https://us3.api.mailchimp.com/3.0"
    },
    "mailService": {
      "transport": {
        "host": "smtp.gmail.com",
        "port": 465,
        "secure": true,
        "user": "vuestorefront",
        "pass": "vuestorefront.io"
      },
      "targetAddressWhitelist": [
        "contributors@vuestorefront.io"
      ],
      "secretString": "__THIS_IS_SO_SECRET__"
    },
    "example-processor": {
      "resultProcessors": {
        "product": "my-product-processor"
      }
    }
  },
  "magento2": {
    "imgUrl": "http://localhost/magento232/pub/media/catalog/product",
    "assetPath": "/../var/magento2-sample-data/pub/media",
    "api": {
      "url": "http://localhost/magento232/rest",
      "consumerKey": "ovmko5wnpn91iqii7e2snd7bib4df9gg",
      "consumerSecret": "iqbnt69mhvqp33tbj2lnlwkhwccsj1oy",
      "accessToken": "rs4qdr78efvq0gioyg3ochnlcp3e6cso",
      "accessTokenSecret": "2jld4czk8w37zu24iyof40y6jmzos73h"
    },
    "url": "http://localhost/magento232"
  },
  "magento1": {
    "imgUrl": "http://magento-demo.local/media/catalog/product",
    "assetPath": "",
    "magentoUserName": "",
    "magentoUserPassword": "",
    "httpUserName": "",
    "httpUserPassword": "",
    "api": {
      "url": "http://magento-demo.local/vsbridge",
      "consumerKey": "",
      "consumerSecret": "",
      "accessToken": "",
      "accessTokenSecret": ""
    }
  },
  "imageable": {
    "maxListeners": 512,
    "imageSizeLimit": 1024,
    "whitelist": {
      "allowedHosts": [
        ".*divante.pl",
        ".*vuestorefront.io",
        "localhost"
      ]
    },
    "cache": {
      "memory": 50,
      "files": 20,
      "items": 100
    },
    "concurrency": 0,
    "counters": {
      "queue": 2,
      "process": 4
    },
    "simd": true
  },
  "entities": {
    "category": {
      "includeFields": [
        "children_data",
        "id",
        "children_count",
        "sku",
        "name",
        "is_active",
        "parent_id",
        "level",
        "url_key"
      ]
    },
    "attribute": {
      "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"
      ]
    },
    "productList": {
      "sort": "",
      "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"
      ],
      "excludeFields": [
        "configurable_children",
        "description",
        "configurable_options",
        "sgn"
      ]
    },
    "productListWithChildren": {
      "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"
      ],
      "excludeFields": [
        "description",
        "sgn"
      ]
    },
    "product": {
      "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"
      ],
      "includeFields": null,
      "filterFieldMapping": {
        "category.name": "category.name.keyword"
      }
    }
  },
  "usePriceTiers": false,
  "boost": {
    "name": 3,
    "category.name": 1,
    "short_description": 1,
    "description": 1,
    "sku": 1,
    "configurable_children.sku": 1
  }
}

I installed a fresh magento 2.3.2 with two stores ( store id 1,2) Initially it worked all data is imported.Once i delete the store 1 and run the importer again i got the same error.

Is it a bug or I am missing something else.

pkarw commented 5 years ago

Hi there, in the API the storeId is being taken from query parameter: https://github.com/DivanteLtd/vue-storefront-api/blob/d3d0e7892cd063bbd69e545f3f2b6fdd9843d524/src/api/product.js#L40

Frontend app is taking storeId from config: https://github.com/DivanteLtd/vue-storefront/blob/4b9f089c6eb732b0cf06191af80bdf3fb18a9bff/core/lib/multistore.ts#L87

... and then pass it ovet to the API as a query parameter: https://github.com/DivanteLtd/vue-storefront/blob/4b9f089c6eb732b0cf06191af80bdf3fb18a9bff/core/modules/catalog/store/product/actions.ts#L111

Thereof, you should change the store id in the config if you have only one store please do change config.storeId otherwise the config.storeViews.<your_store>.storeId

insaurabh commented 5 years ago

Hi @pkarw

I tried what you suggested, I changed in config files at the project root, even I hardcoded the store id in product.js still it hit the store_id =1.

It was the problem in mage2vs data import.

The process of data import was stuck when it gets a non-existing store id. For a temporary solution of this, I looked into mage2vuestorefront/src/config.js in this file, it is using some environment variables.

I set MAGENTO_STORE_ID=2(my store id) in environment variables, then it works perfectly.

Is it the correct way to solve the issues or still i am missing something.

Thank You.

pkarw commented 5 years ago

Hi there! Are You sure the Vue-storefront-api configuration file does contain the proper storeViews section? Please take a look at: https://github.com/DivanteLtd/vue-storefront-api/blob/d7b6fe516eeb214615f54726fb382e72ff2cc34b/scripts/mage2vs.js#L93 - it’s setting exactly this ENV variable just before running magento2vuestorefront? It was created very long time ago so I can miss something; please just try to debug this piece of vs-api code which is in charge of mage2vs import