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

@@ -86,6 +86,9 @@ class WBC_Admin {
register_setting( 'wbc_sync', 'wbc_enable_brand_sync', array(
'sanitize_callback' => array( $this, 'sanitize_checkbox' ),
) );
register_setting( 'wbc_sync', 'wbc_category_parent_map', array(
'sanitize_callback' => 'sanitize_textarea_field',
) );
// Order settings (own group)
register_setting( 'wbc_orders', 'wbc_enable_order_sync', array(