File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,8 @@ public function addProductFilter($products)
219
219
if (!is_array ($ products )) {
220
220
$ products = [$ products ];
221
221
}
222
- $ this ->getSelect ()->where ('links.product_id IN (?) ' , $ products );
222
+ $ identifierField = $ this ->getMetadataPool ()->getMetadata (ProductInterface::class)->getIdentifierField ();
223
+ $ this ->getSelect ()->where ("cpe. $ identifierField IN (?) " , $ products );
223
224
$ this ->_hasLinkFilter = true ;
224
225
}
225
226
@@ -258,6 +259,7 @@ protected function _beforeLoad()
258
259
{
259
260
if ($ this ->getLinkModel ()) {
260
261
$ this ->_joinLinks ();
262
+ $ this ->joinProductsToLinks ();
261
263
}
262
264
return parent ::_beforeLoad ();
263
265
}
@@ -431,4 +433,15 @@ protected function getMetadataPool()
431
433
}
432
434
return $ this ->metadataPool ;
433
435
}
436
+
437
+ /**
438
+ * Join Product To Links
439
+ * @return void
440
+ */
441
+ protected function joinProductsToLinks ()
442
+ {
443
+ $ linkField = $ this ->getMetadataPool ()->getMetadata (ProductInterface::class)->getLinkField ();
444
+ $ this ->getSelect ()
445
+ ->join (['cpe ' => 'catalog_product_entity ' ], "links.product_id = cpe. $ linkField " , []);
446
+ }
434
447
}
You can’t perform that action at this time.
0 commit comments