Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
*/
protected $_itemIds;

/**
* True when selections appended
*
* @var bool
*/
protected $_selectionsAppended = false;

/**
* Init model and resource model
*
Expand Down Expand Up @@ -132,10 +125,10 @@ public function setPositionOrder()
public function appendSelections($selectionsCollection, $stripBefore = false, $appendAll = true)
{
if ($stripBefore) {
$this->_stripSelections();
$this->_stripSelections($selectionsCollection);
}

if (!$this->_selectionsAppended) {
if (!$selectionsCollection->getFlag('has_options_appended')) {
foreach ($selectionsCollection->getItems() as $key => $selection) {
$option = $this->getItemById($selection->getOptionId());
if ($option) {
Expand All @@ -147,7 +140,7 @@ public function appendSelections($selectionsCollection, $stripBefore = false, $a
}
}
}
$this->_selectionsAppended = true;
$selectionsCollection->setFlag('has_options_appended', true);
}

return $this->getItems();
Expand All @@ -156,14 +149,21 @@ public function appendSelections($selectionsCollection, $stripBefore = false, $a
/**
* Removes appended selections before
*
* @param \Magento\Framework\Data\Collection $selectionsCollection
* @return $this
*/
protected function _stripSelections()
protected function _stripSelections(\Magento\Framework\Data\Collection $selectionsCollection)
{
foreach ($this->getItems() as $option) {
$option->setSelections([]);
}
$this->_selectionsAppended = false;

foreach ($selectionsCollection->getItems() as $selection) {
$selection->setOption(null);
}

$selectionsCollection->setFlag('has_options_appended', false);

return $this;
}

Expand Down