Skip to content

Commit fbfd7ce

Browse files
committed
Bundle _prepareProduct cannot be called twice with different selections
1 parent 9b977b0 commit fbfd7ce

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
1717
*/
1818
protected $_itemIds;
1919

20-
/**
21-
* True when selections appended
22-
*
23-
* @var bool
24-
*/
25-
protected $_selectionsAppended = false;
26-
2720
/**
2821
* Init model and resource model
2922
*
@@ -132,10 +125,10 @@ public function setPositionOrder()
132125
public function appendSelections($selectionsCollection, $stripBefore = false, $appendAll = true)
133126
{
134127
if ($stripBefore) {
135-
$this->_stripSelections();
128+
$this->_stripSelections($selectionsCollection);
136129
}
137130

138-
if (!$this->_selectionsAppended) {
131+
if (!$selectionsCollection->getFlag('has_options_appended')) {
139132
foreach ($selectionsCollection->getItems() as $key => $selection) {
140133
$option = $this->getItemById($selection->getOptionId());
141134
if ($option) {
@@ -147,7 +140,7 @@ public function appendSelections($selectionsCollection, $stripBefore = false, $a
147140
}
148141
}
149142
}
150-
$this->_selectionsAppended = true;
143+
$selectionsCollection->setFlag('has_options_appended', true);
151144
}
152145

153146
return $this->getItems();
@@ -156,14 +149,21 @@ public function appendSelections($selectionsCollection, $stripBefore = false, $a
156149
/**
157150
* Removes appended selections before
158151
*
152+
* @param \Magento\Framework\Data\Collection $selectionsCollection
159153
* @return $this
160154
*/
161-
protected function _stripSelections()
155+
protected function _stripSelections(\Magento\Framework\Data\Collection $selectionsCollection)
162156
{
163157
foreach ($this->getItems() as $option) {
164158
$option->setSelections([]);
165159
}
166-
$this->_selectionsAppended = false;
160+
161+
foreach ($selectionsCollection->getItems() as $selection) {
162+
$selection->setOption(null);
163+
}
164+
165+
$selectionsCollection->setFlag('has_options_appended', false);
166+
167167
return $this;
168168
}
169169

0 commit comments

Comments
 (0)