File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
app/code/Magento/Bundle/Model/ResourceModel
dev/tests/integration/testsuite/Magento/Bundle/Model/Product Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ public function getParentIdsByChild($childId)
126
126
'e. ' . $ metadata ->getLinkField () . ' = ' . $ this ->getMainTable () . '.parent_product_id ' ,
127
127
['e.entity_id as parent_product_id ' ]
128
128
)->where (
129
- ' e.entity_id IN(?) ' ,
129
+ $ this -> getMainTable () . ' .product_id IN(?) ' ,
130
130
$ childId
131
131
);
132
132
Original file line number Diff line number Diff line change @@ -77,4 +77,23 @@ public function testGetOptionsCollection()
77
77
$ options = $ bundleType ->getOptionsCollection ($ bundleProduct );
78
78
$ this ->assertCount (5 , $ options ->getItems ());
79
79
}
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
+ }
80
99
}
You can’t perform that action at this time.
0 commit comments