Repository navigation
fix(products): a product or group named like another gets a slug of its own - #187
Merged
Merged
Conversation
Owner
|
Thank you, @ertugrulkeyvan, merged. A product or group named like an existing one now gets a slug of its own, so every product in the store can be ordered, and installs that already had shared slugs are put right by the migration while the oldest product keeps its address. Checked before merging: the four behaviour tests and the migration test fail on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A product or group with the same name as an existing one now gets its own slug (
vps-s-2), so it can be ordered.Products and product groups took
Str::slug($name)as it came. The order page finds a product by its slug (store/configure/{product:slug}), andproducts.slugis not unique, so a second product called like an earlier one:We ran into it while drafting a new catalogue next to an old one that had the same plan names. A second product group with the same name is refused by the unique index on
product_groups.slugwith a 500 (Duplicate entry … product_groups_slug_unique).After this:
-2,-3, and so on.productorgroup, and a suffix if that is taken too.How
App\Support\UniqueSlug::for($model, $name, $fallback, $ignoreId):Str::slug, the fallback when that is empty, and a suffix until no other row has it.ProductCreator, used by the product screen and the API'sAddProduct;ProductController::storeGroup.2026_10_12_000001: walks the products by id and re-slugs only the ones whose slug is empty or already taken by an older product.The work is split into three commits: the fix, the migration, and the tests.
Tests
tests/Feature/ProductSlugTest.php, 5 tests:vps-s,vps-s-2andvps-s-3.专业版getsproduct.shared-hostingandshared-hosting-2.vps-skeeps it, the others get-2and-3, an empty slug is filled, and an unrelated product is untouched.The first four fail on
main.Full suite: 4133 passed. The one failure is the
CurrencyAndBackupTestdb backup test, which fails onmaintoo in my local setup.