Skip to content

Commit e4a63bb

Browse files
committed
AC-711::Fixed Static Tests
1 parent 8fb935e commit e4a63bb

File tree

1 file changed

+20
-48
lines changed

1 file changed

+20
-48
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Magento\Store\Model\Store;
2727
use Magento\Catalog\Model\ResourceModel\Category;
2828
use Zend_Db_Expr;
29+
use Magento\Catalog\Model\ResourceModel\Product\Gallery;
2930

3031
/**
3132
* Product collection
@@ -310,6 +311,9 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
310311
* @param PriceTableResolver|null $priceTableResolver
311312
* @param DimensionFactory|null $dimensionFactory
312313
* @param Category|null $categoryResourceModel
314+
* @param DbStorage|null $urlFinder
315+
* @param GalleryReadHandler|null $productGalleryReadHandler
316+
* @param Gallery|null $mediaGalleryResource
313317
*
314318
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
315319
*/
@@ -339,7 +343,10 @@ public function __construct(
339343
TableMaintainer $tableMaintainer = null,
340344
PriceTableResolver $priceTableResolver = null,
341345
DimensionFactory $dimensionFactory = null,
342-
Category $categoryResourceModel = null
346+
Category $categoryResourceModel = null,
347+
DbStorage $urlFinder = null,
348+
GalleryReadHandler $productGalleryReadHandler = null,
349+
Gallery $mediaGalleryResource = null
343350
) {
344351
$this->moduleManager = $moduleManager;
345352
$this->_catalogProductFlatState = $catalogProductFlatState;
@@ -369,25 +376,19 @@ public function __construct(
369376
$storeManager,
370377
$connection
371378
);
372-
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
373-
$this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class);
379+
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()
380+
->get(TableMaintainer::class);
381+
$this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()
382+
->get(PriceTableResolver::class);
374383
$this->dimensionFactory = $dimensionFactory
375384
?: ObjectManager::getInstance()->get(DimensionFactory::class);
376385
$this->categoryResourceModel = $categoryResourceModel ?: ObjectManager::getInstance()
377386
->get(Category::class);
378-
}
379-
380-
/**
381-
* Retrieve urlFinder
382-
*
383-
* @return GalleryReadHandler
384-
*/
385-
private function getUrlFinder()
386-
{
387-
if ($this->urlFinder === null) {
388-
$this->urlFinder = ObjectManager::getInstance()->get(DbStorage::class);
389-
}
390-
return $this->urlFinder;
387+
$this->urlFinder = $urlFinder ?: ObjectManager::getInstance()->get(DbStorage::class);
388+
$this->productGalleryReadHandler = $productGalleryReadHandler ?: ObjectManager::getInstance()
389+
->get(GalleryReadHandler::class);
390+
$this->mediaGalleryResource = $mediaGalleryResource ?: ObjectManager::getInstance()
391+
->get(Gallery::class);
391392
}
392393

393394
/**
@@ -1461,7 +1462,7 @@ protected function _addUrlRewrite()
14611462
$filter['metadata']['category_id'] = $this->_urlRewriteCategory;
14621463
}
14631464

1464-
$rewrites = $this->getUrlFinder()->findAllByData($filter);
1465+
$rewrites = $this->urlFinder->findAllByData($filter);
14651466
foreach ($rewrites as $rewrite) {
14661467
if ($item = $this->getItemById($rewrite->getEntityId())) {
14671468
$item->setData('request_path', $rewrite->getRequestPath());
@@ -2347,7 +2348,7 @@ public function addMediaGalleryData()
23472348
$items = $this->getItems();
23482349
$linkField = $this->getProductEntityMetadata()->getLinkField();
23492350

2350-
$select = $this->getMediaGalleryResource()
2351+
$select = $this->mediaGalleryResource
23512352
->createBatchBaseSelect(
23522353
$this->getStoreId(),
23532354
$this->getAttribute('media_gallery')->getAttributeId()
@@ -2369,7 +2370,7 @@ function ($item) use ($linkField) {
23692370
}
23702371

23712372
foreach ($items as $item) {
2372-
$this->getGalleryReadHandler()
2373+
$this->productGalleryReadHandler
23732374
->addMediaDataToProduct(
23742375
$item,
23752376
$mediaGalleries[$item->getOrigData($linkField)] ?? []
@@ -2391,35 +2392,6 @@ public function getProductEntityMetadata()
23912392
return $this->metadataPool->getMetadata(ProductInterface::class);
23922393
}
23932394

2394-
/**
2395-
* Retrieve GalleryReadHandler
2396-
*
2397-
* @return GalleryReadHandler
2398-
* @deprecated 101.0.1
2399-
*/
2400-
private function getGalleryReadHandler()
2401-
{
2402-
if ($this->productGalleryReadHandler === null) {
2403-
$this->productGalleryReadHandler = ObjectManager::getInstance()->get(GalleryReadHandler::class);
2404-
}
2405-
return $this->productGalleryReadHandler;
2406-
}
2407-
2408-
/**
2409-
* Retrieve Media gallery resource.
2410-
*
2411-
* @deprecated 101.0.1
2412-
*
2413-
* @return \Magento\Catalog\Model\ResourceModel\Product\Gallery
2414-
*/
2415-
private function getMediaGalleryResource()
2416-
{
2417-
if (null === $this->mediaGalleryResource) {
2418-
$this->mediaGalleryResource = ObjectManager::getInstance()->get(Gallery::class);
2419-
}
2420-
return $this->mediaGalleryResource;
2421-
}
2422-
24232395
/**
24242396
* Clear collection
24252397
*

0 commit comments

Comments
 (0)