fix: correct category-page size and brand/category source of truth

Two fixes bundled together:

1. Shrink CATEGORY_PAGE_SIZE from 100 to 25. Each item in a category page
   can trigger several sequential BC calls (location stock, price lists,
   brand/category lookup) beyond the page fetch itself - at 100 items/page
   this measured 150-250+ seconds on live data, exceeding PHP's execution
   limit and leaving the Action Scheduler action stuck "in-progress"
   forever instead of completing or failing visibly.

2. BC's Item Category table has no parent-category field - confirmed via
   the actual published CategProd endpoint (Code, Description only) and
   the standard itemCategories entity (id, code, displayName only). The
   original ItemCategoryHierarchy AL snippet assumed a Parent Category
   field that doesn't exist. Switched to the standard /itemCategories API
   for the brand display name (no custom endpoint needed for that part),
   and replaced the BC-side parent-category walk with a WordPress-side
   manual map (wbc_category_parent_map: "CODE=Parent Name" per line) for
   the WooCommerce product category grouping, since BC has nothing to
   offer there.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-09 14:41:59 +02:00
parent 0a08086272
commit 8f45ccbee4
4 changed files with 83 additions and 29 deletions

View File

@@ -29,8 +29,16 @@ class WBC_Batch_Sync {
/**
* Number of BC items fetched per page in category-filtered mode
*
* Kept small on purpose: each item can trigger several sequential BC
* calls while processing it (location stock, price lists, brand/category
* lookup), not just the one page fetch. 100 items/page was measured to
* take 150-250+ seconds per page - long enough to exceed PHP's
* execution limit and strand the action mid-run ("in-progress" forever,
* never completing or erroring). Matches BATCH_SIZE, which is proven to
* finish reliably within one execution.
*/
const CATEGORY_PAGE_SIZE = 100;
const CATEGORY_PAGE_SIZE = 25;
/**
* Option name storing the current/last run's progress