Skip to content

Commit 6b5ad76

Browse files
ACPT-488
updating unit tests fixing static test failures
1 parent 4fc1199 commit 6b5ad76

File tree

2 files changed

+49
-313
lines changed

2 files changed

+49
-313
lines changed

app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\CatalogUrlRewrite\Observer;
88

9-
use Magento\Catalog\Api\Data\ProductInterface;
109
use Magento\Catalog\Model\Category;
1110
use Magento\Catalog\Model\Product;
1211
use Magento\Catalog\Model\Product\Visibility;
@@ -51,25 +50,25 @@ class AfterImportDataObserver implements ObserverInterface
5150

5251
/**
5352
* @var StoreViewService
54-
* @deprecated
53+
* @deprecated No longer used.
5554
*/
5655
protected $storeViewService;
5756

5857
/**
5958
* @var Product
60-
* @deprecated
59+
* @deprecated No longer used.
6160
*/
6261
protected $product;
6362

6463
/**
6564
* @var array
66-
* @deprecated
65+
* @deprecated No longer used.
6766
*/
6867
protected $productsWithStores;
6968

7069
/**
7170
* @var array
72-
* @deprecated
71+
* @deprecated No longer used.
7372
*/
7473
protected $products = [];
7574

@@ -197,6 +196,7 @@ class AfterImportDataObserver implements ObserverInterface
197196
* @param ScopeConfigInterface|null $scopeConfig
198197
* @param CollectionFactory|null $collectionFactory
199198
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
199+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
200200
*/
201201
public function __construct(
202202
ProductFactory $catalogProductFactory,
@@ -275,7 +275,7 @@ private function populateForUrlsGeneration(array $bunch) : array
275275
}
276276
}
277277
}
278-
foreach($productIdsMissingUrlKeyByStore as $storeId => $productIds) {
278+
foreach ($productIdsMissingUrlKeyByStore as $storeId => $productIds) {
279279
$this->getUrlKeyAndNameForProductsByIds($productIds, $storeId, $products);
280280
}
281281
return $products;
@@ -286,7 +286,7 @@ private function populateForUrlsGeneration(array $bunch) : array
286286
*
287287
* @param array $rowData
288288
* @param Product[] &$products
289-
* @return AfterImportDataObserver|null
289+
* @return void
290290
* @throws LocalizedException
291291
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
292292
*/
@@ -450,7 +450,6 @@ private function canonicalUrlRewriteGenerate(array $products)
450450
}
451451
}
452452
}
453-
454453
return $urls;
455454
}
456455

@@ -579,18 +578,17 @@ private function generateForCustom(UrlRewrite $url, ?Category $category, array $
579578
if ($url->getRequestPath() === $targetPath) {
580579
return [];
581580
}
582-
return [
583-
$this->urlRewriteFactory->create()
584-
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
585-
->setEntityId($productId)
586-
->setRequestPath($url->getRequestPath())
587-
->setTargetPath($targetPath)
588-
->setRedirectType($url->getRedirectType())
589-
->setStoreId($storeId)
590-
->setDescription($url->getDescription())
591-
->setIsAutogenerated(0)
592-
->setMetadata($url->getMetadata())
593-
];
581+
$urlRewrite = $this->urlRewriteFactory->create();
582+
$urlRewrite->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE);
583+
$urlRewrite->setEntityId($productId);
584+
$urlRewrite->setRequestPath($url->getRequestPath());
585+
$urlRewrite->setTargetPath($targetPath);
586+
$urlRewrite->setRedirectType($url->getRedirectType());
587+
$urlRewrite->setStoreId($storeId);
588+
$urlRewrite->setDescription($url->getDescription());
589+
$urlRewrite->setIsAutogenerated(0);
590+
$urlRewrite->setMetadata($url->getMetadata());
591+
return [$urlRewrite];
594592
}
595593
return [];
596594
}
@@ -681,7 +679,7 @@ private function getParentCategoriesUrlRewrites(array $categoryIds, int $storeId
681679
*
682680
* @param int[] $productIds
683681
* @param int $storeId
684-
* @param array[] $products
682+
* @param array[] $importedProducts
685683
* @return void
686684
*/
687685
private function getUrlKeyAndNameForProductsByIds(array $productIds, int $storeId, array $importedProducts): void

0 commit comments

Comments
 (0)