@@ -69,15 +69,11 @@ class DataProvider
6969 private $ productAttributeCollectionFactory ;
7070
7171 /**
72- * Eav config
73- *
7472 * @var Config
7573 */
7674 private $ eavConfig ;
7775
7876 /**
79- * Catalog product type
80- *
8177 * @var Type
8278 */
8379 private $ catalogProductType ;
@@ -90,8 +86,6 @@ class DataProvider
9086 private $ eventManager ;
9187
9288 /**
93- * Store manager
94- *
9589 * @var StoreManagerInterface
9690 */
9791 private $ storeManager ;
@@ -155,6 +149,7 @@ class DataProvider
155149 * @param int $antiGapMultiplier
156150 * @param GetSearchableProductsSelect|null $getSearchableProductsSelect
157151 * @throws Exception
152+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
158153 */
159154 public function __construct (
160155 ResourceConnection $ resource ,
@@ -178,7 +173,8 @@ public function __construct(
178173 $ this ->engine = $ engineProvider ->get ();
179174 $ this ->metadata = $ metadataPool ->getMetadata (ProductInterface::class);
180175 $ this ->antiGapMultiplier = $ antiGapMultiplier ;
181- $ this ->selectSearchableProducts = $ getSearchableProductsSelect ?: ObjectManager::getInstance ()->get (GetSearchableProductsSelect::class);
176+ $ this ->selectSearchableProducts = $ getSearchableProductsSelect ?:
177+ ObjectManager::getInstance ()->get (GetSearchableProductsSelect::class);
182178 }
183179
184180 /**
@@ -210,7 +206,13 @@ public function getSearchableProducts(
210206 $ lastProductId = 0 ,
211207 $ batch = 100
212208 ) {
213- $ select = $ this ->selectSearchableProducts ->execute ((int )$ storeId , $ staticFields , $ productIds , $ lastProductId , $ batch );
209+ $ select = $ this ->selectSearchableProducts ->execute (
210+ (int ) $ storeId ,
211+ $ staticFields ,
212+ $ productIds ,
213+ $ lastProductId ,
214+ $ batch
215+ );
214216 if ($ productIds === null ) {
215217 $ select ->where (
216218 'e.entity_id < ? ' ,
@@ -221,7 +223,13 @@ public function getSearchableProducts(
221223 if ($ productIds === null && !$ products ) {
222224 // try to search without limit entity_id by batch size for cover case with a big gap between entity ids
223225 $ products = $ this ->connection ->fetchAll (
224- $ this ->selectSearchableProducts ->execute ((int )$ storeId , $ staticFields , $ productIds , $ lastProductId , $ batch )
226+ $ this ->selectSearchableProducts ->execute (
227+ (int ) $ storeId ,
228+ $ staticFields ,
229+ $ productIds ,
230+ $ lastProductId ,
231+ $ batch
232+ )
225233 );
226234 }
227235
@@ -576,12 +584,14 @@ private function getAttributeValue($attributeId, $valueIds, $storeId)
576584 * @param int $attributeId
577585 * @param int|string $valueIds
578586 * @param int $storeId
587+ *
579588 * @return null|string
589+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
580590 */
581591 private function getAttributeOptionValue ($ attributeId , $ valueIds , $ storeId )
582592 {
583593 $ optionKey = $ attributeId . '- ' . $ storeId ;
584- $ attributeValueIds = explode (', ' , $ valueIds );
594+ $ attributeValueIds = $ valueIds !== null ? explode (', ' , $ valueIds ) : [] ;
585595 $ attributeOptionValue = '' ;
586596 if (!array_key_exists ($ optionKey , $ this ->attributeOptions )
587597 ) {
@@ -615,11 +625,11 @@ function ($value) {
615625 /**
616626 * Remove whitespaces and tags from attribute value
617627 *
618- * @param string $value
628+ * @param string|null $value
619629 * @return string
620630 */
621- private function filterAttributeValue ($ value )
631+ private function filterAttributeValue (? string $ value )
622632 {
623- return preg_replace ('/\s+/iu ' , ' ' , trim (strip_tags ($ value )));
633+ return $ value !== null ? preg_replace ('/\s+/iu ' , ' ' , trim (strip_tags ($ value ))) : '' ;
624634 }
625635}
0 commit comments