File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
app/code/Magento/ConfigurableProduct/Pricing/Price Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,13 @@ class LowestPriceOptionsProvider implements LowestPriceOptionsProviderInterface
30
30
*/
31
31
private $ collectionFactory ;
32
32
33
+ /**
34
+ * Key is product id. Value is prepared product collection
35
+ *
36
+ * @var array
37
+ */
38
+ private $ productsMap ;
39
+
33
40
/**
34
41
* @param ResourceConnection $resourceConnection
35
42
* @param LinkedProductSelectBuilderInterface $linkedProductSelectBuilder
@@ -50,14 +57,16 @@ public function __construct(
50
57
*/
51
58
public function getProducts (ProductInterface $ product )
52
59
{
53
- $ productIds = $ this ->resource ->getConnection ()->fetchCol (
54
- '( ' . implode (') UNION ( ' , $ this ->linkedProductSelectBuilder ->build ($ product ->getId ())) . ') '
55
- );
56
-
57
- $ lowestPriceChildProducts = $ this ->collectionFactory ->create ()
58
- ->addAttributeToSelect (['price ' , 'special_price ' ])
59
- ->addIdFilter ($ productIds )
60
- ->getItems ();
61
- return $ lowestPriceChildProducts ;
60
+ if (!isset ($ this ->productsMap [$ product ->getId ()])) {
61
+ $ productIds = $ this ->resource ->getConnection ()->fetchCol (
62
+ '( ' . implode (') UNION ( ' , $ this ->linkedProductSelectBuilder ->build ($ product ->getId ())) . ') '
63
+ );
64
+
65
+ $ this ->productsMap [$ product ->getId ()] = $ this ->collectionFactory ->create ()
66
+ ->addAttributeToSelect (['price ' , 'special_price ' ])
67
+ ->addIdFilter ($ productIds )
68
+ ->getItems ();
69
+ }
70
+ return $ this ->productsMap [$ product ->getId ()];
62
71
}
63
72
}
You can’t perform that action at this time.
0 commit comments