=== Asperor Merchant Feed Generator ===
Contributors: radilov
Tags: woocommerce, google merchant center, product feed, polylang, scheduled fetch
Requires at least: 6.8
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 2.1.0
License: GPLv2 or later

Generates valid Google Merchant Center product feeds from your live WooCommerce catalog - one feed for a single-language store, or one per language if Polylang is installed.

== Description ==

Asperor Merchant Feed Generator is the merged successor to two previously separate plugins, **Asperor Multilanguage Merchant Feed** and **Asperor One Language Merchant Feed**. Both generated the same kind of feed with the same row-building logic underneath; the only real difference was whether the catalog got split by Polylang language or not. Keeping them as two separately-evolving codebases meant fixes and features landed in one and not the other - this plugin ends that by detecting Polylang at runtime and behaving as either, from a single codebase:

* **Polylang installed and configured** - one feed per language, filtered by each product's real Polylang language (not the site's admin locale, which is what makes Google for WooCommerce mislabel multilingual catalogs).
* **Polylang absent** - a single feed with the whole catalog.

Public REST endpoints:

`/wp-json/asperor-merchant-feed-generator/v1/feed/{lang}`  (multilingual)
`/wp-json/asperor-merchant-feed-generator/v1/feed`         (single-language)

Sites migrating from either predecessor plugin can keep their existing Merchant Center data sources unchanged - the old endpoints keep working as aliases of the same feed:

`/wp-json/b2b-merchant-feed/v1/feed/{lang}`             (was Asperor Multilanguage Merchant Feed)
`/wp-json/asperor-primary-merchant-feed/v1/feed`        (was Asperor One Language Merchant Feed)

= Features =

* Store-agnostic category mapping: map each WooCommerce product category to the correct Google product category from an admin screen, searchable against Google's full official taxonomy (bundled). Categories left unmapped send an empty `google_product_category` so Google auto-detects from title/description instead of getting a wrong guess. Optional per-product override via post meta `_amfg_google_category_override`.
* Real per-variation offers: variable products expand into one row per published variation, with `item_group_id` linking them - the correct Google Shopping pattern for color/size variants, instead of only sending the first variation.
* `brand`, `color`, `size`, `gender` and `age_group` are read from whichever attribute name the store actually uses (`pa_color`/`color`/`colour`/`pa_colore`, etc.), not one hardcoded name. `gender`/`age_group` are only sent for products resolved into a Google "Apparel & Accessories" category - never a hardcoded default.
* `mpn` filled from the product/variation SKU automatically.
* Admin screen ("Merchant Feed") listing the feed URL(s), live product counts, category mapping, and Merchant Center setup steps.
* Fully translatable (English source strings, Spanish translation included).

== Requirements ==

* WordPress 6.8+
* WooCommerce
* Polylang - optional, only if you want one feed per language.

== Installation ==

1. Upload the plugin ZIP in WordPress admin.
2. Activate Asperor Merchant Feed Generator.
3. Go to Merchant Feed in the admin menu.
4. Map your product categories to Google's taxonomy (recommended - see Category mapping section).
5. Copy the feed URL(s) into Google Merchant Center as a primary source with Scheduled fetch.

== Changelog ==

= 2.1.0 =
* Without an active license, the feed is now capped at 5 products (still fully valid TSV, just a shorter catalog) instead of exporting the whole store indefinitely for free.

= 2.0.0 =
* Merged "Asperor Multilanguage Merchant Feed" and "Asperor One Language Merchant Feed" into a single plugin. Polylang is now detected at runtime instead of being a hard requirement: one feed per language when present, a single feed when not.
* Everything from Multilanguage Merchant Feed 1.2.0 (color/mpn/brand fallbacks) is superseded by the more general mechanisms already in this codebase (category mapping, multi-name attribute detection) - see below.
* Legacy REST endpoint aliases added (`b2b-merchant-feed/v1/...`, `asperor-primary-merchant-feed/v1/feed`) so sites migrating from either predecessor keep their existing Merchant Center data sources working without re-registering them.

= 1.3.0 (as Asperor One Language Merchant Feed) =
* Store-agnostic category mapping: a new "Category mapping" admin screen lets you map each WooCommerce product
  category to the correct Google product category, searchable against Google's full official taxonomy (bundled).
  Replaces the old apparel-only keyword guesser, which silently miscategorized every product on any non-clothing
  store (e.g. sent pet supplies, electronics, etc. to Google as "Apparel & Accessories > Clothing").
* Unmapped categories now send an empty google_product_category instead of a wrong guess, so Google auto-detects
  from title/description instead.
* gender and age_group are now only sent for products resolved into a Google "Apparel & Accessories" category,
  and are read from the product's own gender/age-group attributes if present — never a hardcoded default.
* Optional per-product override: set post meta to a Google category ID to bypass the category mapping for a single product.

= 1.2.1 (as Asperor One Language Merchant Feed) =
* Single-language variant of Asperor Merchant Feed.
* Removed Polylang dependency and language taxonomy filtering.
* Added variation rows with item group, color and size fields.
* Added product_type and public single-feed endpoint.
