Skip to content

Commit 68cc2d9

Browse files
author
Yaroslav Onischenko
committed
Merge remote-tracking branch 'origin/MAGETWO-62681' into SEGFAULT_BANNERS_PR
2 parents 1f54cd1 + 9491491 commit 68cc2d9

File tree

2 files changed

+20
-1
lines changed
  • app/code/Magento/Bundle/Model/ResourceModel
  • dev/tests/integration/testsuite/Magento/Bundle/Model/Product

2 files changed

+20
-1
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Selection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function getParentIdsByChild($childId)
126126
'e.' . $metadata->getLinkField() . ' = ' . $this->getMainTable() . '.parent_product_id',
127127
['e.entity_id as parent_product_id']
128128
)->where(
129-
'e.entity_id IN(?)',
129+
$this->getMainTable() . '.product_id IN(?)',
130130
$childId
131131
);
132132

dev/tests/integration/testsuite/Magento/Bundle/Model/Product/TypeTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,23 @@ public function testGetOptionsCollection()
7777
$options = $bundleType->getOptionsCollection($bundleProduct);
7878
$this->assertCount(5, $options->getItems());
7979
}
80+
81+
/**
82+
* @magentoDataFixture Magento/Bundle/_files/product.php
83+
* @covers \Magento\Bundle\Model\Product\Type::getParentIdsByChild()
84+
*/
85+
public function testGetParentIdsByChild()
86+
{
87+
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
88+
/** @var \Magento\Catalog\Api\Data\ProductInterface $bundleProduct */
89+
$bundleProduct = $productRepository->get('bundle-product');
90+
/** @var \Magento\Catalog\Api\Data\ProductInterface $simpleProduct */
91+
$simpleProduct = $productRepository->get('simple');
92+
93+
/** @var \Magento\Bundle\Model\Product\Type $bundleType */
94+
$bundleType = $bundleProduct->getTypeInstance();
95+
$parentIds = $bundleType->getParentIdsByChild($simpleProduct->getId());
96+
$this->assertNotEmpty($parentIds);
97+
$this->assertEquals($bundleProduct->getId(), $parentIds[0]);
98+
}
8099
}

0 commit comments

Comments
 (0)