55 */
66namespace Magento \Sitemap \Model \ResourceModel \Catalog ;
77
8- use Magento \Catalog \Helper \Product as HelperProduct ;
98use Magento \Catalog \Model \Product \Image \UrlBuilder ;
109use Magento \CatalogUrlRewrite \Model \ProductUrlRewriteGenerator ;
1110use Magento \Framework \App \ObjectManager ;
12- use Magento \Store \Model \ScopeInterface ;
1311use Magento \Store \Model \Store ;
1412
1513/**
@@ -82,28 +80,11 @@ class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
8280 */
8381 protected $ _mediaConfig ;
8482
85- /**
86- * @var \Magento\Catalog\Model\Product
87- */
88- private $ productModel ;
89-
90- /**
91- * @var \Magento\Catalog\Helper\Image
92- */
93- private $ catalogImageHelper ;
94-
9583 /**
9684 * @var UrlBuilder
9785 */
9886 private $ imageUrlBuilder ;
9987
100- /**
101- * Scope Config
102- *
103- * @var \Magento\Framework\App\Config\ScopeConfigInterface
104- */
105- private $ scopeConfig ;
106-
10788 /**
10889 * Product constructor.
10990 *
@@ -122,6 +103,7 @@ class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
122103 * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $scopeConfig
123104 * @param UrlBuilder $urlBuilder
124105 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
106+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
125107 */
126108 public function __construct (
127109 \Magento \Framework \Model \ResourceModel \Db \Context $ context ,
@@ -147,13 +129,7 @@ public function __construct(
147129 $ this ->mediaGalleryReadHandler = $ mediaGalleryReadHandler ;
148130 $ this ->_mediaConfig = $ mediaConfig ;
149131 $ this ->_sitemapData = $ sitemapData ;
150- $ this ->productModel = $ productModel ?: ObjectManager::getInstance ()->get (\Magento \Catalog \Model \Product::class);
151- $ this ->catalogImageHelper = $ catalogImageHelper ;
152132 $ this ->imageUrlBuilder = $ urlBuilder ?? ObjectManager::getInstance ()->get (UrlBuilder::class);
153- $ this ->catalogImageHelper = $ catalogImageHelper ?: ObjectManager::getInstance ()
154- ->get (\Magento \Catalog \Helper \Image::class);
155- $ this ->scopeConfig = $ scopeConfig ?: ObjectManager::getInstance ()
156- ->get (\Magento \Framework \App \Config \ScopeConfigInterface::class);
157133
158134 parent ::__construct ($ context , $ connectionName );
159135 }
@@ -311,11 +287,6 @@ public function getCollection($storeId)
311287 }
312288
313289 $ connection = $ this ->getConnection ();
314- $ urlRewriteMetaDataCondition = '' ;
315- if (!$ this ->isCategoryProductURLsConfig ($ storeId )) {
316- $ urlRewriteMetaDataCondition = ' AND url_rewrite.metadata IS NULL ' ;
317- }
318-
319290 $ this ->_select = $ connection ->select ()->from (
320291 ['e ' => $ this ->getMainTable ()],
321292 [$ this ->getIdFieldName (), $ this ->_productResource ->getLinkField (), 'updated_at ' ]
@@ -326,7 +297,7 @@ public function getCollection($storeId)
326297 )->joinLeft (
327298 ['url_rewrite ' => $ this ->getTable ('url_rewrite ' )],
328299 'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1 '
329- . $ urlRewriteMetaDataCondition
300+ . ' AND url_rewrite.metadata IS NULL '
330301 . $ connection ->quoteInto (' AND url_rewrite.store_id = ? ' , $ store ->getId ())
331302 . $ connection ->quoteInto (' AND url_rewrite.entity_type = ? ' , ProductUrlRewriteGenerator::ENTITY_TYPE ),
332303 ['url ' => 'request_path ' ]
@@ -490,20 +461,4 @@ private function getProductImageUrl($image)
490461 {
491462 return $ this ->imageUrlBuilder ->getUrl ($ image , 'product_page_image_large ' );
492463 }
493-
494- /**
495- * Return Use Categories Path for Product URLs config value
496- *
497- * @param null|string $storeId
498- *
499- * @return bool
500- */
501- private function isCategoryProductURLsConfig ($ storeId )
502- {
503- return $ this ->scopeConfig ->isSetFlag (
504- HelperProduct::XML_PATH_PRODUCT_URL_USE_CATEGORY ,
505- ScopeInterface::SCOPE_STORE ,
506- $ storeId
507- );
508- }
509464}
0 commit comments