@@ -23,6 +23,11 @@ class GetPriceConfigurationObserver implements ObserverInterface
23
23
*/
24
24
protected $ registry ;
25
25
26
+ /**
27
+ * @var array Cache of the current bundle selection items
28
+ */
29
+ private $ selectionCache = [];
30
+
26
31
/**
27
32
* @param \Magento\Framework\Registry $registry
28
33
* @param \Magento\Tax\Helper\Data $taxData
@@ -44,6 +49,7 @@ public function __construct(
44
49
*/
45
50
public function execute (\Magento \Framework \Event \Observer $ observer )
46
51
{
52
+ $ this ->selectionCache = [];
47
53
if ($ this ->taxData ->displayPriceIncludingTax ()) {
48
54
/** @var \Magento\Catalog\Model\Product $product */
49
55
$ product = $ this ->registry ->registry ('current_product ' );
@@ -107,15 +113,19 @@ private function updatePriceForBundle($holder, $key)
107
113
/** @var \Magento\Catalog\Model\Product $product */
108
114
$ product = $ this ->registry ->registry ('current_product ' );
109
115
if ($ product ->getTypeId () == \Magento \Catalog \Model \Product \Type::TYPE_BUNDLE ) {
110
- $ typeInstance = $ product ->getTypeInstance ();
111
- $ typeInstance ->setStoreFilter ($ product ->getStoreId (), $ product );
116
+ if (!isset ($ this ->selectionCache [$ product ->getId ()])) {
117
+ $ typeInstance = $ product ->getTypeInstance ();
118
+ $ typeInstance ->setStoreFilter ($ product ->getStoreId (), $ product );
112
119
113
- $ selectionCollection = $ typeInstance ->getSelectionsCollection (
114
- $ typeInstance ->getOptionsIds ($ product ),
115
- $ product
116
- );
120
+ $ selectionCollection = $ typeInstance ->getSelectionsCollection (
121
+ $ typeInstance ->getOptionsIds ($ product ),
122
+ $ product
123
+ );
124
+ $ this ->selectionCache [$ product ->getId ()] = $ selectionCollection ->getItems ();
125
+ }
126
+ $ arrSelections = $ this ->selectionCache [$ product ->getId ()];
117
127
118
- foreach ($ selectionCollection -> getItems () as $ selectionItem ) {
128
+ foreach ($ arrSelections as $ selectionItem ) {
119
129
if ($ holder ['optionId ' ] == $ selectionItem ->getId ()) {
120
130
/** @var \Magento\Framework\Pricing\Amount\Base $baseAmount */
121
131
$ baseAmount = $ selectionItem ->getPriceInfo ()->getPrice (BasePrice::PRICE_CODE )->getAmount ();
0 commit comments