@@ -17,13 +17,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
17
17
*/
18
18
protected $ _itemIds ;
19
19
20
- /**
21
- * True when selections appended
22
- *
23
- * @var bool
24
- */
25
- protected $ _selectionsAppended = false ;
26
-
27
20
/**
28
21
* Init model and resource model
29
22
*
@@ -132,10 +125,10 @@ public function setPositionOrder()
132
125
public function appendSelections ($ selectionsCollection , $ stripBefore = false , $ appendAll = true )
133
126
{
134
127
if ($ stripBefore ) {
135
- $ this ->_stripSelections ();
128
+ $ this ->_stripSelections ($ selectionsCollection );
136
129
}
137
130
138
- if (!$ this -> _selectionsAppended ) {
131
+ if (!$ selectionsCollection -> getFlag ( ' has_options_appended ' ) ) {
139
132
foreach ($ selectionsCollection ->getItems () as $ key => $ selection ) {
140
133
$ option = $ this ->getItemById ($ selection ->getOptionId ());
141
134
if ($ option ) {
@@ -147,7 +140,7 @@ public function appendSelections($selectionsCollection, $stripBefore = false, $a
147
140
}
148
141
}
149
142
}
150
- $ this -> _selectionsAppended = true ;
143
+ $ selectionsCollection -> setFlag ( ' has_options_appended ' , true ) ;
151
144
}
152
145
153
146
return $ this ->getItems ();
@@ -156,14 +149,21 @@ public function appendSelections($selectionsCollection, $stripBefore = false, $a
156
149
/**
157
150
* Removes appended selections before
158
151
*
152
+ * @param \Magento\Framework\Data\Collection $selectionsCollection
159
153
* @return $this
160
154
*/
161
- protected function _stripSelections ()
155
+ protected function _stripSelections (\ Magento \ Framework \ Data \ Collection $ selectionsCollection )
162
156
{
163
157
foreach ($ this ->getItems () as $ option ) {
164
158
$ option ->setSelections ([]);
165
159
}
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
+
167
167
return $ this ;
168
168
}
169
169
0 commit comments