API Pagination Needed for Product Endpoint
-
Hi team,
Been using the Product Rearrange plug-in, you have an issue in the backend where it loads all products in a single API call. Our server can handle it usually, however we just enabled Redis caching and now the plug-in is dead. It's minified so I can't tell much but JS file looks like the products need the same pagination logic as the categories applied. Cheers! Suggested solution:
/*
Q = function () {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : -1,
t = arguments.length > 1 ? arguments[1] : void 0,
r = arguments.length > 2 ? arguments[2] : void 0;
return function () {
var n = q(U().mark((function n(o) {
var i, a, s, l, c, u, d;
return U().wrap((function (n) {
for (;;) switch (n.prev = n.next) {
case 0:
if (0 === t.length) {
n.next = 26;
break
}
i = [], a = 1, s = 1, n.prev = 4;
case 5:
if (!(a <= s)) {
n.next = 18;
break
}
l = -1 !== e ? e : "", c = new z.ZP({
url: r,
consumerKey: t.key,
consumerSecret: t.secret,
wpAPI: !0,
version: "wc/v3",
queryStringAuth: !0,
axiosConfig: {
headers: {}
}
}), n.next = 9, c.get("products", {
orderby: "menu_order",
order: "asc",
category: l,
status: "publish",
per_page: 100,
page: a
});
case 9:
u = n.sent, i = i.concat(u.data), s = u.headers["x-wp-totalpages"], a++, n.next = 5;
break;
case 15:
d = i, o({
type: K,
payload: d
}), n.next = 26;
break;
case 19:
n.prev = 19, n.t0 = n.catch(4), o({
type: Y,
payload: n.t0
}), console.log("Failed to fetch products:", n.t0);
case 23:
case "end":
return n.stop()
}
}), n, null, [
[4, 19]
])
})));
return function (e) {
return n.apply(this, arguments)
}
}()
};
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘API Pagination Needed for Product Endpoint’ is closed to new replies.