Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: include seo urls within product entity (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus authored Oct 20, 2020
1 parent 534465b commit dd74d2e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 16 deletions.
2 changes: 1 addition & 1 deletion api/shopware-6-client.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const getCategoryProducts: (categoryId: string, criteria?: ShopwareSearch
// @alpha
export const getCategoryProductsListing: (categoryId: string, searchCriteria?: SearchCriteria | undefined, contextInstance?: ShopwareApiInstance) => Promise<ProductListingResult>;

// @alpha (undocumented)
// @beta (undocumented)
export function getCmsPage(path: string, criteria?: ShopwareSearchParams, contextInstance?: ShopwareApiInstance): Promise<PageResolverResult<CmsPage>>;

// @beta
Expand Down
31 changes: 31 additions & 0 deletions docs/landing/resources/api/shopware-6-client.getcmspage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@shopware-pwa/shopware-6-client](./shopware-6-client.md) &gt; [getCmsPage](./shopware-6-client.getcmspage.md)

## getCmsPage() function

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>
<b>Signature:</b>

```typescript
export declare function getCmsPage(path: string, criteria?: ShopwareSearchParams, contextInstance?: ShopwareApiInstance): Promise<PageResolverResult<CmsPage>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| path | string | |
| criteria | ShopwareSearchParams | |
| contextInstance | [ShopwareApiInstance](./shopware-6-client.shopwareapiinstance.md) | |

<b>Returns:</b>

Promise&lt;[PageResolverResult](./shopware-6-client.pageresolverresult.md)<!-- -->&lt;CmsPage&gt;&gt;

## Exceptions

ClientApiError

1 change: 1 addition & 0 deletions docs/landing/resources/api/shopware-6-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
| [changeCartItemQuantity(itemId, newQuantity, contextInstance)](./shopware-6-client.changecartitemquantity.md) | <b><i>(BETA)</i></b> Changes the current quantity in specific cart line item to given quantity.<!-- -->Example: If current quantity is 3 and you pass 2 as quantity parameter, you will get a new cart's state with quantity 2. |
| [createInstance(initialConfig)](./shopware-6-client.createinstance.md) | <b><i>(BETA)</i></b> |
| [getCart(contextInstance)](./shopware-6-client.getcart.md) | <b><i>(BETA)</i></b> Gets the current cart for the sw-context-token. |
| [getCmsPage(path, criteria, contextInstance)](./shopware-6-client.getcmspage.md) | <b><i>(BETA)</i></b> |
| [getCustomer(contextInstance)](./shopware-6-client.getcustomer.md) | <b><i>(BETA)</i></b> Get customer's object |
| [getCustomerAddresses(contextInstance)](./shopware-6-client.getcustomeraddresses.md) | <b><i>(BETA)</i></b> Get all customer's addresses |
| [getCustomerOrders(contextInstance)](./shopware-6-client.getcustomerorders.md) | <b><i>(BETA)</i></b> Get all customer's orders |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"translated",
"options",
"properties",
"manufacturer"
"manufacturer",
"seoUrls"
],
"product_media": ["media"],
"media": ["thumbnails", "width", "height", "url"],
Expand Down Expand Up @@ -139,7 +140,8 @@
"cover",
"id",
"translated",
"options"
"options",
"seoUrls"
],
"product_media": ["media"],
"media": ["thumbnails", "width", "height", "url"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ describe("PageService - getCmsPage", () => {
});
const result = await getCmsPage("Sports/Grocery-Garden");
expect(mockedPost).toBeCalledTimes(1);
expect(mockedPost).toBeCalledWith("/store-api/v3/pwa/page", {
path: "Sports/Grocery-Garden",
});
expect(mockedPost).toBeCalledWith(
"/store-api/v3/pwa/page",
{
path: "Sports/Grocery-Garden",
},
{ headers: { "sw-include-seo-urls": true } }
);
expect(result).toHaveProperty("cmsPage");
expect(result.cmsPage.id).toEqual("b218f861361042f3a58a2a9d1b3575b5");
});
Expand All @@ -36,10 +40,14 @@ describe("PageService - getCmsPage", () => {
limit: 3,
});
expect(mockedPost).toBeCalledTimes(1);
expect(mockedPost).toBeCalledWith("/store-api/v3/pwa/page", {
path: "Sports/Grocery-Garden",
p: 2,
limit: 3,
});
expect(mockedPost).toBeCalledWith(
"/store-api/v3/pwa/page",
{
path: "Sports/Grocery-Garden",
p: 2,
limit: 3,
},
{ headers: { "sw-include-seo-urls": true } }
);
});
});
18 changes: 13 additions & 5 deletions packages/shopware-6-client/src/services/pageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,25 @@ export async function getPage(

/**
* @throws ClientApiError
* @alpha
* @beta
*/
export async function getCmsPage(
path: string,
criteria?: ShopwareSearchParams,
contextInstance: ShopwareApiInstance = defaultInstance
): Promise<PageResolverResult<CmsPage>> {
const resp = await contextInstance.invoke.post(getPageResolverEndpoint(), {
path: path,
...criteria,
});
const resp = await contextInstance.invoke.post(
getPageResolverEndpoint(),
{
path: path,
...criteria,
},
{
headers: {
"sw-include-seo-urls": true,
},
}
);

return resp.data;
}
Expand Down

1 comment on commit dd74d2e

@vercel
Copy link

@vercel vercel bot commented on dd74d2e Oct 20, 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.