Skip to content

Commit

Permalink
feat(composables): handle the includes parameter within the product l…
Browse files Browse the repository at this point in the history
…isting #553 (#918)
  • Loading branch information
mkucmus authored Jul 2, 2020
1 parent 8b3d94f commit 213d488
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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,
});

1 comment on commit 213d488

@vercel
Copy link

@vercel vercel bot commented on 213d488 Jul 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.