Skip to content

Commit 50487e5

Browse files
authored
ENGCOM-5300: Fixes issue #13227 #22650
2 parents d0fde13 + 88dddaa commit 50487e5

File tree

2 files changed

+5
-6
lines changed
  • app/code/Magento/Catalog/Model/Product
  • dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import

2 files changed

+5
-6
lines changed

app/code/Magento/Catalog/Model/Product/Url.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ public function getUrl(\Magento\Catalog\Model\Product $product, $params = [])
162162
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
163163
);
164164

165-
if ($categoryId) {
166-
$filterData[UrlRewrite::METADATA]['category_id'] = $categoryId;
167-
} elseif (!$useCategories) {
168-
$filterData[UrlRewrite::METADATA]['category_id'] = '';
169-
}
165+
$filterData[UrlRewrite::METADATA]['category_id']
166+
= $categoryId && $useCategories ? $categoryId : '';
170167

171168
$rewrite = $this->urlFinder->findOneByData($filterData);
172169

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
use Magento\Framework\App\Bootstrap;
2121
use Magento\Framework\App\Filesystem\DirectoryList;
2222
use Magento\Framework\App\ObjectManager;
23+
use Magento\Framework\Exception\NoSuchEntityException;
2324
use Magento\Framework\Filesystem;
2425
use Magento\Framework\Registry;
2526
use Magento\ImportExport\Model\Import;
2627
use Magento\Store\Model\Store;
2728
use Psr\Log\LoggerInterface;
28-
use Magento\Framework\Exception\NoSuchEntityException;
2929

3030
/**
3131
* Class ProductTest
@@ -95,6 +95,7 @@ protected function tearDown()
9595
try {
9696
$product = $productRepository->get($productSku, false, null, true);
9797
$productRepository->delete($product);
98+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
9899
} catch (NoSuchEntityException $e) {
99100
// nothing to delete
100101
}
@@ -1097,6 +1098,7 @@ public function testProductsWithMultipleStores()
10971098
/**
10981099
* Test url keys properly generated in multistores environment.
10991100
*
1101+
* @magentoConfigFixture current_store catalog/seo/product_use_categories 1
11001102
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
11011103
* @magentoDataFixture Magento/Catalog/_files/category_with_two_stores.php
11021104
* @magentoDbIsolation enabled

0 commit comments

Comments
 (0)