Skip to content

Fix feed importer and categories #3297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

devbodaghe
Copy link
Contributor

@devbodaghe devbodaghe commented Jun 4, 2025

Description

This PR fixes critical performance and functionality issues in the Facebook for WooCommerce plugin's Google Product Category system that were causing browser crashes and "Page Unresponsive" errors.

Primary Issue: The plugin was loading all 5,582 Google product categories (525KB of JSON data) into the browser simultaneously, overwhelming memory and causing crashes, particularly on product edit pages for feed-imported products.

Root Cause: Feed-imported products with Google Product Categories containing HTML entities (like 'Clothing & Accessories > Clothing > Shirts & Tops') triggered loading of the entire category dataset during hierarchy reconstruction, exhausting browser memory.

Solution: Implemented progressive loading architecture that reduces initial payload from 525KB to ~6KB (98.9% reduction) while maintaining full functionality through on-demand AJAX loading.

Additional Fixes:

  • Restored Enhanced Catalog Attributes ("Show More Attributes") functionality that was broken
  • Fixed category persistence for both feed-imported and manually created products
  • Resolved duplicate AJAX handlers causing UI duplication
  • Fixed CSS styling issues and removed unwanted white space
  • Added support for category name/path resolution from feed imports
  • Improved error handling with graceful fallbacks

Dependencies: No new dependencies required. Uses existing WordPress AJAX infrastructure.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Performance improvement (non-breaking change which improves efficiency)

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
  • I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
  • I followed general Pull Request best practices.
  • I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
  • I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
  • I have updated or requested update to plugin documentations (if necessary).

Changelog entry

Fix Google Product Category browser crashes by implementing progressive loading (6KB vs 525KB), restore Enhanced Catalog Attributes functionality, and improve category persistence for imported products.

Test Plan

Test Environment:

  • WordPress with WooCommerce and Facebook for WooCommerce plugin
  • Products imported from feed files with Google Product Categories
  • Manually created products with Google Product Categories

Test Cases:

  1. Performance Test:

    • Navigate to product edit page for feed-imported product (previously crashed)
    • Verify page loads without "Page Unresponsive" errors
    • Confirm Google Product Category dropdowns render properly
    • Measure network payload (should be ~6KB vs previous 525KB)
  2. Category Persistence Test:

    • Edit feed-imported product with existing category (e.g., "Clothing & Accessories > Clothing > Shirts & Tops")
    • Verify category dropdowns show correct selection hierarchy
    • Save product and reload - confirm category persists
    • Repeat with manually created product
  3. Enhanced Attributes Test:

    • Select valid Google Product Category (2+ levels deep)
    • Verify "Show More Attributes" checkbox appears
    • Check checkbox and confirm additional attribute fields display
    • Verify no duplicate "Show More Attributes" checkboxes
  4. Progressive Loading Test:

    • Open category dropdown - verify top-level categories load
    • Select category - verify children load dynamically via AJAX
    • Navigate through category hierarchy - confirm smooth operation
    • Monitor network tab for AJAX requests

Screenshots

Before

  • Browser "Page Unresponsive" dialog when editing products with Google Product Categories
  • Network tab showing 525KB payload for Google Product Category data
  • Missing "Show More Attributes" functionality
  • Empty category dropdowns on feed-imported products
  • Duplicate "Show More Attributes" checkboxes appearing

After

  • Product edit pages load smoothly without crashes
  • Network tab showing ~6KB initial payload with progressive AJAX loading
  • Google Product Category dropdowns properly display hierarchical selection
  • "Show More Attributes" functionality working correctly (single checkbox)
  • Feed-imported products show correct category selections
  • Enhanced attributes fields appear when valid categories selected
  • Clean UI with proper CSS styling and no unwanted white space

Performance Metrics:

  • Initial payload: 525KB → 6KB (98.9% reduction)
  • Page load time: Improved significantly
  • Memory usage: Drastically reduced
  • Browser crashes: Eliminated

@devbodaghe devbodaghe force-pushed the fix-feed-importer-and-categories branch from b6b119b to 45162aa Compare June 4, 2025 17:16
@facebook-github-bot
Copy link
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@devbodaghe devbodaghe force-pushed the fix-feed-importer-and-categories branch from 0791b64 to f15155c Compare June 4, 2025 17:29
@facebook-github-bot
Copy link
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

David Evbodaghe added 10 commits June 11, 2025 16:07
…ategory UI with Select2 dependency and simplified JavaScript
…ment progressive loading (6KB vs 525KB), fix category persistence for imported/created products, restore Enhanced Catalog Attributes functionality, remove duplicate AJAX handlers, fix CSS styling, clean up debug logs, add category path reconstruction and name lookup handlers, improve error handling, prevent browser crashes
@devbodaghe devbodaghe force-pushed the fix-feed-importer-and-categories branch from f15155c to 6930fc2 Compare June 11, 2025 15:08
@facebook-github-bot
Copy link
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants