Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure proper retrieval of parent entity_id #688

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ public function getSearchableProducts($storeId, $productIds = null, $fromId = 0,
*/
public function getRelationsByChild($childrenIds)
{
$metadata = $this->getEntityMetaData(\Magento\Catalog\Api\Data\ProductInterface::class);
$entityTable = $this->getTable($metadata->getEntityTable());
$relationTable = $this->getTable('catalog_product_relation');
$joinCondition = sprintf('relation.parent_id = entity.%s', $metadata->getLinkField());

$select = $this->getConnection()->select()
->from($this->resource->getTableName('catalog_product_relation'), 'parent_id')
->where('child_id IN(?)', $childrenIds);
->from(['relation' => $relationTable], [])
->join(['entity' => $entityTable], $joinCondition, [$metadata->getIdentifierField()])
->where('child_id IN(?)', array_map('intval', $childrenIds));

return $this->getConnection()->fetchCol($select);
}
Expand Down