• 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)
  • Thread Starter hsx34001

    (@hsx34001)

    Tested and working:
    
    
    
    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, currentPage, totalPages, fetchedData;
    return U().wrap(function(n) {
    for (;;) switch (n.prev = n.next) {
    case 0:
    if (0 === t.length) {
    n.next = 20;
    break
    }
    o({
    type: X
    });
    i = -1 !== e ? e : "";
    a = new z.ZP({
    url: r,
    consumerKey: t.key,
    consumerSecret: t.secret,
    wpAPI: !0,
    version: "wc/v3",
    queryStringAuth: !0,
    axiosConfig: {
    headers: {}
    }
    });
    fetchedData = [];
    currentPage = 1;
    totalPages = 1;
    case 7:
    if (!(currentPage <= totalPages)) {
    n.next = 17;
    break
    }
    n.next = 10;
    return a.get("products", {
    orderby: "menu_order",
    order: "asc",
    category: i,
    status: "publish",
    per_page: 100,
    page: currentPage
    });
    case 10:
    s = n.sent;
    totalPages = parseInt(s.headers["x-wp-totalpages"], 10);
    fetchedData = fetchedData.concat(s.data);
    currentPage++;
    n.next = 7;
    break;
    case 17:
    o({
    type: K,
    payload: fetchedData
    });
    n.next = 20;
    break;
    case 20:
    case "end":
    return n.stop()
    }
    })
    }));
    return function(e) {
    return n.apply(this, arguments)
    }
    }()
    },

    I’d perhaps not load all products on the main page initially, you will take down many sites with 1000s of products.

    We have < 1000 and the load size is 14mb+

    Plugin Author Devteam HaywoodTech

    (@haywoodtech)

    Hello,

    Thank you for choosing our plugin. Your observation regarding performance is greatly appreciated. We will address this matter in our upcoming update and notify you once it’s resolved. We appreciate your feedback.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘API Pagination Needed for Product Endpoint’ is closed to new replies.