Skip to content

Commit 9dcdc29

Browse files
committed
MAGETWO-53305: [Staging] When update was applied Cross-Sells data are not displayed in the shopping cart
1 parent a5fa3af commit 9dcdc29

File tree

1 file changed

+14
-1
lines changed
  • app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ public function addProductFilter($products)
219219
if (!is_array($products)) {
220220
$products = [$products];
221221
}
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);
223224
$this->_hasLinkFilter = true;
224225
}
225226

@@ -258,6 +259,7 @@ protected function _beforeLoad()
258259
{
259260
if ($this->getLinkModel()) {
260261
$this->_joinLinks();
262+
$this->joinProductsToLinks();
261263
}
262264
return parent::_beforeLoad();
263265
}
@@ -431,4 +433,15 @@ protected function getMetadataPool()
431433
}
432434
return $this->metadataPool;
433435
}
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+
}
434447
}

0 commit comments

Comments
 (0)