/** * Clear collection * * @return $this */ public function clear() { foreach ($this->_items as $i => $item) { if ($item->hasStockItem()) { $item->unsStockItem(); } $this->_items[$i] = null; } foreach ($this->_itemsById as $i => $item) { $this->_itemsById[$i] = null; } unset($this->_items, $this->_data, $this->_itemsById); $this->_data = []; return parent::clear(); }