Skip to content

Commit 03a1500

Browse files
committed
ACP2E-1783: Unable to create 301/302 redirect for product with a category path when Generate "category/product" URL Rewrites set to Yes
- refactored solution
1 parent a73b032 commit 03a1500

File tree

1 file changed

+3
-2
lines changed
  • app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite

1 file changed

+3
-2
lines changed

app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ protected function getTargetPath($model)
9999
if (!$rewrite) {
100100
$model->getEntityType() === self::ENTITY_TYPE_PRODUCT ? $this->checkProductCorrelation($model) :
101101
$this->checkCategoryCorrelation($model);
102+
} else {
103+
$targetPath = $rewrite->getRequestPath();
102104
}
103-
$targetPath = $rewrite->getRequestPath();
104105
}
105106
return $targetPath;
106107
}
@@ -114,7 +115,7 @@ protected function getTargetPath($model)
114115
*/
115116
private function checkCategoryCorrelation(\Magento\UrlRewrite\Model\UrlRewrite $model): void
116117
{
117-
if (false === ($this->_getCategory()->getStoreId() == $model->getStoreId())) {
118+
if (false === in_array($model->getStoreId(), $this->_getCategory()->getStoreIds())) {
118119
throw new LocalizedException(
119120
__("The selected category isn't associated with the selected store.")
120121
);

0 commit comments

Comments
 (0)