WooCommerce Product Sorter
Score and sort WooCommerce products by search relevancy.
#about
Connects to the WooCommerce REST API (wc/v3) to sort products within categories by relevancy using FuzzyWuzzy token_sort_ratio.
Compares product names against category names to calculate similarity scores.
Batch updates menu_order via API to reorder products.
Paginates the category fetch (100 per page) and fetches up to 100 products per category.
Dual timeout settings (120s send/receive).
Streamlit app
- Platform
- Browser-based (no installation required)
- Input
- WooCommerce store URLConsumer key and consumer secret API credentials
- Output
- Products automatically reordered within WooCommerce categories by relevancy score. Console shows category names, product counts, and sorted listings.
- Category
- E-commerce
Use cases
- Improving default product sorting in WooCommerce
- Ensuring products appear in logical order based on category names
#features
- WooCommerce REST API v3 integration
- FuzzyWuzzy token_sort_ratio scoring (ties broken alphabetically)
- Batch POST updates for menu_order values
- Category pagination (100 per page); products fetched one page per category (API default 10)
- 120-second send/receive timeouts for large catalogues
- Console output: category names, product counts, sorted listings
#how-to-use
- Enter WooCommerce store URL and read/write API credentials
- Tool fetches all categories, then the first page of products per category
- FuzzyWuzzy scores each product name against its category name
- Batch updates menu_order live via products/batch (no dry run)
- Set storefront sorting to Default sorting so menu_order takes effect
#faq
- Why did only some products in each category get reordered?
- The product fetch does not paginate. Categories are fetched 100 per page until exhausted, but products are requested with a single call per category and no per_page parameter, and the WooCommerce REST API returns 10 items per request by default. Only that first page of products is scored and given a menu_order. Add pagination or a per_page parameter to the products request if your categories are larger.
- Does this change my live store immediately?
- Yes. It POSTs menu_order updates via the products/batch endpoint as it processes each category, with no dry-run or preview mode. Run it against a staging site first. The new order is only visible on the storefront when the catalogue sort option is Default sorting, which is what respects menu_order.
- What happens to products in more than one category?
- menu_order is a single field on the product, not a per-category value, so a product appearing in several categories gets its menu_order overwritten each time one of its categories is processed. It keeps whichever position was written last, which may not suit its other categories.
- How is the relevancy score calculated?
- FuzzyWuzzy token_sort_ratio between the product name and the category name, a 0 to 100 score that tokenises and sorts words before comparing, so word order does not matter. Ties are broken alphabetically by product name. It is purely lexical: a 'TIG Welding Torch' scores well in 'Welding Torches', but synonyms or model-number-only names score poorly.
- What API credentials does it need?
- A WooCommerce REST API consumer key and secret with Read/Write permission, created under WooCommerce > Settings > Advanced > REST API, plus your store URL. The script uses API version wc/v3 with 120-second send and receive timeouts for large catalogues.
/contact
Want me to run this for you? I run this tool as a managed service, or build something custom around your data. You get the insights without touching the code.