Skip to content

Commit

Permalink
feat: enhance SEO URL fetching to remove not buyable products and ord…
Browse files Browse the repository at this point in the history
…er placement logic
  • Loading branch information
shyim committed Nov 18, 2024
1 parent c721ea8 commit 68b4a33
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
41 changes: 40 additions & 1 deletion fetch-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,52 @@ async function fetchSeoUrls(name: string) {
limit: 500,
});

const data = seoUrls.body.data.map((seoUrl) => {
let data = seoUrls.body.data.map((seoUrl) => {
return {
url: `${salesChannel.url}/${seoUrl.seoPathInfo}`,
id: seoUrl.foreignKey,
};
});

if (name === 'frontend.detail.page') {
const productIds = data.map((seoUrl) => seoUrl.id);

const filteredProductIds = await apiClient.post<{data: string[]}>('/search-ids/product', {
ids: productIds,
filter: [
{
type: "equals",
field: "active",
value: true,
},
{
type: 'multi',
operator: 'OR',
queries: [
{
type: "equals",
field: "childCount",
value: 0,
},
{
type: "not",
operator: "AND",
queries: [
{
type: "equals",
field: "parentId",
value: null
}
]
}
]
}
]
}, {"sw-inheritance": "1"});

data = data.filter((seoUrl) => filteredProductIds.body.data.includes(seoUrl.id));
}

Bun.write(`fixtures/seo-${name}.json`, JSON.stringify(data));
console.log(`Collected ${data.length} seo urls for ${name}`);
}
Expand Down
3 changes: 2 additions & 1 deletion helpers/storefront.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ export function visitSearchPage() {
export function placeOrder(orderCounter) {
const res = postFormData(`${salesChannel[0].url}/checkout/order`, {
tos: "on",
revocation: "on",
}, 'frontend.checkout.order');

const orderPlaced = check(res, {
"Order placed": (r) => r.status === 200 && r.body.includes("finish-order-details"),
});

if (orderPlaced) {
if (orderPlaced && orderCounter) {
orderCounter.add(1);
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "k6-shopware",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "benchmark.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit 68b4a33

Please sign in to comment.