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 endpoint
  • Loading branch information
mkucmus committed Jul 1, 2020
1 parent 8b3d94f commit 3e35c09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 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,8 @@ export const useProductListing = (
name: "productReviews",
},
],
// performance enhancement - fetch only the relevant fields
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,
});

0 comments on commit 3e35c09

Please sign in to comment.