Vue Storefront 2 integration for Magento 2
6672edfb: [CHANGED] magentoModule
has been deprecated. Use middlewareModule
from @vue-storefront/sdk
package instead.
- import { initSDK, buildModule } from '@vue-storefront/sdk';
- import { magentoModule } from '@vsf-enterprise/magento-sdk'
+ import { initSDK, buildModule, middlewareModule } from '@vue-storefront/sdk';
+ import { Endpoints as MagentoEndpoints } from '@vsf-enterprise/sapcc-api'; // In Alokai Storefront you should import it from `storefront-middleware/types.ts`
const sdkConfig = {
magento:
buildModule(
- magentoModule,
+ middlewareModule<MagentoEndpoints>,
{ apiUrl: 'http://localhost:8181/magento' }
)
};
Updating your magentoModule
to this version should not disrupt your existing code; however, switching to middlewareModule
will require certain modifications.
To migrate:
middlewareModule
function.const customQuery = {
cart: 'cart-custom-query',
metadata: {
fields: 'id items { uid }'
}
};
- const cart = await sdk.magento.cart({ cartId: '123'}, { customQuery });
+ const cart = await sdk.magento.cart({ cartId: '123'}, customQuery);
productDetailsQuery
with new fields: stock_status
and only_x_left_in_stock
. #1521
ae8a741d: ### Change Log
MagentoModuleType
interface in index.ts
. It is no longer necessary to use this type. Please, check documentation of magentoModule
for alternatives. Below you can find a snippet of the new way of using magentoModule
. Pay attention to the buildModule
function that is used to create a module instance, it no longer requires the MagentoModuleType
type as a generic parameter.import { initSDK, buildModule } from "@vue-storefront/sdk";
import {
magentoModule,
MagentoModuleType,
} from "@vue-storefront/magento2-sdk";
const sdkConfig = {
magento: buildModule(magentoModule, {
apiUrl: "http://localhost:8181/magento",
}),
};
export const sdk = initSDK(sdkConfig);
ssrApiUrl
property in ModuleOptions.ts
optional.8b8fdff0: - [CHANGED] Endpoints
interface. Previously, each endpoint contained context
param, which is internal and shouldn't be exposed in the final interface. Now, Endpoints
interface properties don't contain context
param. If you need to use context
param, you should use ApiMethods
type.
- import { Endpoints } from '@vue-storefront/magento-api';
+ import { ApiMethods } from '@vue-storefront/magento-api';
ContextualizedEndpoints
type. Use Endpoints
instead.- import { ContextualizedEndpoints } from '@vue-storefront/magento-api';
+ import { Endpoints } from '@vue-storefront/magento-api';
MagentoApiMethods
interface. Use Endpoints
instead.- import { MagentoApiMethods } from '@vue-storefront/magento-api';
+ import { Endpoints } from '@vue-storefront/magento-api';
categories
method that allows fetching a list of categories that match the specified filter.8b2a0c35: [ADDED] categories
endpoint that allows fetching a list of categories that match the specified filter.
[CHANGED] categoryList
endpoint is now deprecated in favor of the new categories
endpoint.
7ce4f9ed: [CHANGED] Enhanced default GQL queries
CategorySearchQuery
new fields:
url_key
- The url key assigned to the category.children
- Child categories tree.
include_in_menu
is_anchor
level
name
position
product_count
uid
url_key
url_path
url_suffix
// get category `children` categories
const category = sdk.commerce.categorySearch();
const children = category.children;
CategoryListQuery
new fields:
children.url_key
- The url key assigned to the category.// get `url_key` of category children
const categoryList = sdk.commerce.categoryList();
for (let categoryChildren of categoryList.children) {
const url_key = categoryChildren.url_key;
}
ProductListsQuery
new fields:
variants
- An array of variants of ConfigurableProduct
// get ConfigurableProduct `variants` products
const products = sdk.commerce.products();
for (let product of products) {
if (product.__typename === "ConfigurableProduct") {
const variants = products.variants;
}
}
7ce4f9ed: [FIXED] CategoryListQuery
returns url_key
property on each children level
[CHANGED] Enhanced default GQL queries
CategoryListQuery
children
7ce4f9ed: [CHANGED] Enhanced default GQL queries
ProductDetailsQuery
ConfigurableProduct
response with ConfigurableVariants
7ce4f9ed: [CHANGED] Enhanced default GQL queries with new fields
CartQuery
CustomerCartQuery
ApplyCouponToCartMutation
RemoveCouponFromCartMutation
AddProductsToCartMutation
RemoveItemFromCartMutation
SetShippingMethodsOnCartMutation
MergeCartsMutation
with new fields:
prices
subtotal_with_discount_excluding_tax
configured_variant
sku
name
only_x_left_in_stock
price_range
7ce4f9ed: [FIXED] getAvailableShippingMethods
method declaration argument type. Using cart_id
instead of cartId
.
7ce4f9ed: [FIXED] updateCustomerAddress
method declaration argument type. Use id
instead of addressId
.
[CHANGED] Enhanced default GQL queries
CreateCustomerAddress
response with fields
firstname
lastname
prefix
suffix
7ce4f9ed: [CHANGED] Enhanced default GQL queries with new fields
SetGuestEmailOnCartMutation
SetBillingAddressOnCartMutation
SetPaymentMethodOnCartMutation
SetShippingAddressesOnCartMutation
with new fields:
prices
subtotal_with_discount_excluding_tax
configured_variant
sku
name
only_x_left_in_stock
price_range
7ce4f9ed: [CHANGED] Enhanced default GQL queries
CategorySearchQuery
new fields:
url_key
- The url key assigned to the category.children
- Child categories tree.
include_in_menu
is_anchor
level
name
position
product_count
uid
url_key
url_path
url_suffix
// get category `children` categories
const category = sdk.commerce.categorySearch();
const children = category.children;
CategoryListQuery
new fields:
children.url_key
- The url key assigned to the category.// get `url_key` of category children
const categoryList = sdk.commerce.categoryList();
for (let categoryChildren of categoryList.children) {
const url_key = categoryChildren.url_key;
}
ProductListsQuery
new fields:
variants
- An array of variants of ConfigurableProduct
// get ConfigurableProduct `variants` products
const products = sdk.commerce.products();
for (let product of products) {
if (product.__typename === "ConfigurableProduct") {
const variants = products.variants;
}
}
7ce4f9ed: [FIXED] CategoryListQuery
returns url_key
property on each children level
[CHANGED] Enhanced default GQL queries
CategoryListQuery
children
7ce4f9ed: [CHANGED] Enhanced default GQL queries
ProductDetailsQuery
ConfigurableProduct
response with ConfigurableVariants
7ce4f9ed: [CHANGED] Enhanced default GQL queries with new fields
CartQuery
CustomerCartQuery
ApplyCouponToCartMutation
RemoveCouponFromCartMutation
AddProductsToCartMutation
RemoveItemFromCartMutation
SetShippingMethodsOnCartMutation
MergeCartsMutation
with new fields:
prices
subtotal_with_discount_excluding_tax
configured_variant
sku
name
only_x_left_in_stock
price_range
7ce4f9ed: [FIXED] updateCustomerAddress
method declaration argument type. Use id
instead of addressId
.
[CHANGED] Enhanced default GQL queries
CreateCustomerAddress
response with fields
firstname
lastname
prefix
suffix
7ce4f9ed: [CHANGED] Enhanced default GQL queries with new fields
SetGuestEmailOnCartMutation
SetBillingAddressOnCartMutation
SetPaymentMethodOnCartMutation
SetShippingAddressesOnCartMutation
with new fields:
prices
subtotal_with_discount_excluding_tax
configured_variant
sku
name
only_x_left_in_stock
price_range
Updated dependencies [7ce4f9ed]
Updated dependencies [7ce4f9ed]
Updated dependencies [7ce4f9ed]
Updated dependencies [7ce4f9ed]
Updated dependencies [7ce4f9ed]
Updated dependencies [7ce4f9ed]
Updated dependencies [7ce4f9ed]