1
+ <?php
2
+ /**
3
+ * integer_net Magento Module
4
+ *
5
+ * @category IntegerNet
6
+ * @package IntegerNet_Solr
7
+ * @copyright Copyright (c) 2016 integer_net GmbH (http://www.integer-net.de/)
8
+ * @author Andreas von Studnitz <avs@integer-net.de>
9
+ */
10
+ class IntegerNet_Solr_Model_Resource_Catalog_Product_Type_Bundle extends Mage_Bundle_Model_Resource_Selection
11
+ {
12
+ /**
13
+ * Retrieve Required children ids
14
+ * Return grouped array, ex array(
15
+ * group => array(ids)
16
+ * )
17
+ *
18
+ * @param null|int[] $parentIds
19
+ * @return int[][]
20
+ */
21
+ public function getChildrenIdsForMultipleParents ($ parentIds )
22
+ {
23
+ $ childrenIds = array ();
24
+ $ adapter = $ this ->_getReadAdapter ();
25
+ $ select = $ adapter ->select ()
26
+ ->from (
27
+ array ('tbl_selection ' => $ this ->getMainTable ()),
28
+ array ('product_id ' , 'parent_product_id ' , 'option_id ' )
29
+ )
30
+ ->join (
31
+ array ('e ' => $ this ->getTable ('catalog/product ' )),
32
+ 'e.entity_id = tbl_selection.product_id AND e.required_options=0 ' ,
33
+ array ()
34
+ )
35
+ ->join (
36
+ array ('tbl_option ' => $ this ->getTable ('bundle/option ' )),
37
+ 'tbl_option.option_id = tbl_selection.option_id ' ,
38
+ array ('required ' )
39
+ );
40
+ if (!is_null ($ parentIds )) {
41
+ $ select ->where ('tbl_selection.parent_product_id IN (?) ' , $ parentIds );
42
+ }
43
+
44
+ foreach ($ this ->_getReadAdapter ()->fetchAll ($ select ) as $ row ) {
45
+ $ childrenIds [$ row ['parent_product_id ' ]][$ row ['product_id ' ]] = $ row ['product_id ' ];
46
+ }
47
+
48
+ return $ childrenIds ;
49
+ }
50
+ }
0 commit comments