-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add a redirection function 301 or 302 on Category page #35608
Conversation
fd82ad9
to
ae3a68c
Compare
c9428df
to
6bbabbe
Compare
e2e07be
to
15130a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @M0rgan01
just a few comments, 7 for 46 files is a decent score 😅
// Target only inputs present in the redirect target row | ||
this.$redirectTargetRow = this.$redirectTargetInput.closest(CategoryMap.redirectOption.groupSelector); | ||
|
||
if (this.$redirectTypeInput.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.$redirectTypeInput.length) { | |
if (this.$redirectTargetInput.length) { |
It's the target that needs to be checked no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the purpose is to make this service more generic to work for both product and category (and maybe some other domain later), then it should be moved into a common namespace, although I'm not sure which one Maybe PrestaShop\PrestaShop\Adapter\SEO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change though, it's ok but you should update the PR description
$this->notFound = true; | ||
if (!$this->category->id_type_redirected) { | ||
if (in_array($this->category->redirect_type, [RedirectType::TYPE_CATEGORY_PERMANENT, RedirectType::TYPE_CATEGORY_TEMPORARY])) { | ||
$this->category->id_type_redirected = $this->category->id_category_default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful I wouldn't trust this field, it is never written/read It has not link to the DB and no domain logic behind (no default category is assigned to a category) I don't know its purpose but I'm not sure it is what you are looking for
In the form we stated that empty value is equivalent to the root category, so I think you need to fetch the root category another way, I don't know if it's in a configuration or if you need to do an SQL request to fetch it though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can use Category::getRootCategory()->id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative I just though about would be to redirect to the parent when the value is left empty, but that's a product decision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MatShir ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent category could be disabled as well. Is it going to redirect to the parent until a parent category is available ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the getRootCategory, which works.
For $this->category->id_type_redirected = $this->category->id_category_default;
, this is code taken from the Product controller, so the remark also applies to the product side
tests/Integration/Behaviour/Features/Scenario/Category/category_management.feature
Show resolved
Hide resolved
@MatShir Yeah, I just wanted to add the |
I corrected it, thank you @florine2623. For point 6, it is the HTTP code of the console which will show you the difference, and for me it is good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @M0rgan01 ,
Some comments on this PR :)
BUG 1 ✅
BUG 2 ✅
BUG 3 ✅
BUG 3 bis ❌
For default category edition, the value is "- No redirection (410)"
We have 404 instead of 410.
BUG 3 ter ❌
The default value is “Permanent redirection to a category (301)”
When I create a new category, the Redirection when offline should be 301 by default, but it is 302.
BUG 4 ✅
BUG 5 ✅
BUG 6 ✅
BUG 7 ✅
Waiting for your feedback :)
Thanks!
0a3d00b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BC breaks:
PrestaShop\PrestaShop\Adapter\Product\Options\RedirectTargetProvider
->PrestaShop\PrestaShop\Adapter\SEO\RedirectTargetProvider
PrestaShop\PrestaShop\Core\Domain\Product\QueryResult\ProductRedirectTarget
->PrestaShop\PrestaShop\Core\Domain\QueryResult\RedirectTargetInformation