Skip to content

Commit 3adc18f

Browse files
SarmisthaSarmistha
authored andcommitted
Merge remote-tracking branch 'magento-l3/ACP2E-2481' into 2.4-develop
2 parents 364d994 + 8c26f02 commit 3adc18f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
109109
*
110110
* @var \Magento\UrlRewrite\Model\UrlRewrite
111111
* @deprecated 102.0.0
112+
* @see \Magento\UrlRewrite\Model\UrlFinderInterface
112113
*/
113114
protected $_urlRewrite;
114115

@@ -315,6 +316,7 @@ protected function getCustomAttributesCodes()
315316
* @throws \Magento\Framework\Exception\LocalizedException
316317
* @return \Magento\Catalog\Model\ResourceModel\Category
317318
* @deprecated 102.0.6 because resource models should be used directly
319+
* @see \Magento\Catalog\Model\ResourceModel\Category
318320
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
319321
* @since 102.0.6
320322
*/
@@ -615,6 +617,7 @@ public function getUrl()
615617
UrlRewrite::ENTITY_ID => $this->getId(),
616618
UrlRewrite::ENTITY_TYPE => CategoryUrlRewriteGenerator::ENTITY_TYPE,
617619
UrlRewrite::STORE_ID => $this->getStoreId(),
620+
UrlRewrite::REDIRECT_TYPE => 0
618621
]
619622
);
620623
if ($rewrite) {

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
use Magento\Catalog\Model\ResourceModel\Category\Collection;
1515
use Magento\Catalog\Model\ResourceModel\Category\Tree;
1616
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
17+
use Magento\Catalog\Test\Fixture\Category as CategoryFixture;
1718
use Magento\Eav\Model\Entity\Attribute\Exception as AttributeException;
19+
use Magento\Framework\Exception\LocalizedException;
1820
use Magento\Framework\Exception\NoSuchEntityException;
1921
use Magento\Framework\Math\Random;
2022
use Magento\Framework\Url;
2123
use Magento\Store\Api\StoreRepositoryInterface;
2224
use Magento\Store\Model\Store;
2325
use Magento\Store\Model\StoreManagerInterface;
26+
use Magento\TestFramework\Fixture\DataFixture;
27+
use Magento\TestFramework\Fixture\DataFixtureStorage;
28+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
2429
use Magento\TestFramework\Helper\Bootstrap;
2530
use PHPUnit\Framework\TestCase;
2631

@@ -57,8 +62,14 @@ class CategoryTest extends TestCase
5762
/** @var CategoryRepositoryInterface */
5863
private $categoryRepository;
5964

65+
/**
66+
* @var DataFixtureStorage
67+
*/
68+
private $dataFixtureStorage;
69+
6070
/**
6171
* @inheritdoc
72+
* @throws LocalizedException
6273
*/
6374
protected function setUp(): void
6475
{
@@ -69,6 +80,7 @@ protected function setUp(): void
6980
$this->_model = $this->objectManager->create(Category::class);
7081
$this->categoryResource = $this->objectManager->get(CategoryResource::class);
7182
$this->categoryRepository = $this->objectManager->get(CategoryRepositoryInterface::class);
83+
$this->dataFixtureStorage = DataFixtureStorageManager::getStorage();
7284
}
7385

7486
public function testGetUrlInstance(): void
@@ -509,4 +521,21 @@ protected function getCategoryByName($categoryName)
509521

510522
return $collection->getItemByColumnValue('name', $categoryName);
511523
}
524+
525+
/**
526+
* @return void
527+
* @throws LocalizedException|\Exception
528+
*/
529+
#[
530+
DataFixture(CategoryFixture::class, as: 'category'),
531+
]
532+
public function testGetUrlAfterUpdate()
533+
{
534+
$category = $this->dataFixtureStorage->get('category');
535+
$category->setUrlKey('new-url');
536+
$category->setSaveRewritesHistory(true);
537+
$this->categoryResource->save($category);
538+
539+
$this->assertStringEndsWith('new-url.html', $category->getUrl());
540+
}
512541
}

0 commit comments

Comments
 (0)