Skip to content
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

slugs are globally unique, not channel unique #2843

Open
mschipperheyn opened this issue May 8, 2024 · 2 comments
Open

slugs are globally unique, not channel unique #2843

mschipperheyn opened this issue May 8, 2024 · 2 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@mschipperheyn
Copy link
Contributor

mschipperheyn commented May 8, 2024

Describe the bug
We wrote a deep channel copier that uses a channel as a template for other channels.
One of the issues we ran into is that the entity duplicators add -copy to slugs. Not a great key for a slug. So we figured, we'll copy the product to the target channel and then remove the -copy of the slug.

Unfortunately, the findOneBySlug function:

  • loads the slug independent of channel on a findOne basis (and therefore hits the slug from the source channel)
  • then loads the resulting product by id on a channel specific basis
  • resulting in a 404

Having globally unique slugs seems like a bug to me, especially within the context of a multi vendor marketplace
What imho should happen is load the product channel specifically left joining the translation slug. That would resolve the issue

@michaelbromley I'm willing to write a fix but since this is core functionality not sure if you agree or want me to touch it.

To Reproduce
Steps to reproduce the behavior:

  1. Copy a product to another channel
  2. Rename the slug back to the original slug
  3. load the product by slug on the shop-api using the token for the new channel
  4. 404

Expected behavior
Product slugs should be unique on a per channel basis.

Environment (please complete the following information):

  • @vendure/core version: 2.2.3
  • Nodejs version 20
  • Database (mysql/postgres etc): postgres

Additional context

@mschipperheyn mschipperheyn added the type: bug 🐛 Something isn't working label May 8, 2024
@oidt
Copy link
Contributor

oidt commented May 9, 2024

Are you using the right approach? For what I know is that a product is assigned to a channel from the default channel and never is copied to a channel.

https://docs.vendure.io/guides/core-concepts/channels/#channels-currencies--prices

@mschipperheyn
Copy link
Contributor Author

What I'm doing might be considered something that wasn't considered as a common scenario but that should be possible and highlights an unnecessary limitation. IMHO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants