Skip to content

feat(clone): gate category cloning behind CLONE_CATEGORIES_ENABLED - #29

Merged
willymwai merged 1 commit into
mainfrom
feat/gate-category-cloning
Jul 7, 2026
Merged

feat(clone): gate category cloning behind CLONE_CATEGORIES_ENABLED#29
willymwai merged 1 commit into
mainfrom
feat/gate-category-cloning

Conversation

@Elias-3817

Copy link
Copy Markdown
Contributor

What this solves

Every AI-generated shop shows several sets of categories (Categories,
Collections, Categories 2) in the storefront menu and footer. It reads as
broken and clutters the shop.

"Categories" in Spree are taxonomies/taxons. A new Spree store seeds no
taxonomies of its own (the built-in seeder is deprecated and unwired), so
the only source of a shop's categories is the clone: StoreCloneRunner's
TaxonomiesDuplicator copies every taxonomy from the template store
verbatim.

Taxonomy/taxon cloning ran unconditionally in StoreCloneRunner, with no
way to turn it off short of editing the template store (which we don't
want to require).

Solution

Gate the taxonomy and taxon duplicators behind a new
CLONE_CATEGORIES_ENABLED environment variable, mirroring the existing
PRODUCTS_CLONE_LIMIT pattern. It defaults to enabled, so behavior is
unchanged until an environment sets CLONE_CATEGORIES_ENABLED=false,
which makes newly cloned shops skip the inherited category trees.

The clone runs inside CloneStoreJob (Sidekiq), so the variable is read in
the worker environment. Product ->taxon links cannot be orphaned: the taxon
cache is left empty when gated and the product duplicator reads it
null-safely (and in production PRODUCTS_CLONE_LIMIT=0 means no products
clone anyway).

Add an env gate around the taxonomy and taxon duplicators in
StoreCloneRunner. When CLONE_CATEGORIES_ENABLED=false the clone skips
copying the template store's taxonomies/taxons, so newly cloned shops
are born without the inherited category clutter (Categories, Collections,
Categories 2) that appears in nav and footer.

Defaults to enabled: when the variable is absent the clone behaves
exactly as before, so the change is inert until deliberately switched
off in an environment. The taxon duplicator is still constructed so its
taxons_cache stays an empty hash when gated; the downstream product
duplicator reads that cache null-safely, so no product->taxon links are
orphaned.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@willymwai
willymwai merged commit 5442954 into main Jul 7, 2026
3 checks passed
@willymwai
willymwai deleted the feat/gate-category-cloning branch July 7, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants