Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(composables): handle the includes parameter within the product listing #553 #918

Merged
merged 2 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/composables/src/hooks/useProductListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
getApplicationContext,
} from "@shopware-pwa/composables";
import { ApplicationVueContext } from "../appContext";
import { getProductListingIncludes } from "../internalHelpers/includesParameter";

/**
* @alpha
Expand Down Expand Up @@ -147,6 +148,9 @@ export const useProductListing = (
name: "productReviews",
},
],
// performance enhancement - fetch only the relevant fields
// TODO: https://github.com/DivanteLtd/shopware-pwa/issues/911
includes: getProductListingIncludes(),
},
};

Expand Down
12 changes: 12 additions & 0 deletions packages/composables/src/internalHelpers/includesParameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,15 @@ export const getPageIncludes = () => ({
product_group_option: PRODUCT_GROUP_OPTION,
product_group: PRODUCT_GROUP,
});

/**
* Parameters for product listing - aligned with getCategoryProductsListing method of @shopware-pwa/shopware-6-client
*/
export const getProductListingIncludes = () => ({
product: PRODUCT,
product_media: PRODUCT_MEDIA,
media: MEDIA,
calculated_price: PRODUCT_CALCULATED_PRICE,
product_group_option: PRODUCT_GROUP_OPTION,
product_group: PRODUCT_GROUP,
});