Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling clear / removeAllItems / removeItemByKey on Magento\Eav\Model\Entity\Collection\AbstractCollection does not remove model from protected _itemsById array #484

Closed
wants to merge 1 commit into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -1533,4 +1533,38 @@ public function getLoadedIds()
{
return array_keys($this->_items);
}

/**
* Clear collection
* @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
*/
public function clear()
{
$this->_itemsById = array();
return parent::clear();
}

/**
* Remove all items from collection
* @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
*/
public function removeAllItems()
{
$this->_itemsById = array();
return parent::removeAllItems();
}

/**
* Remove item from collection by item key
*
* @param mixed $key
* @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
*/
public function removeItemByKey($key)
{
if (isset($this->_items[$key])) {
unset($this->_itemsById[$this->_items[$key]->getId()]);
}
return parent::removeItemByKey($key);
}
}