/** * Override addItem to not attempt to use item id as key, and to set item root and path. * Also to ensure indexing on strings for safety with MongoId * * @param Varien_Object $item * @return Cm_Mongo_Model_Resource_Collection_Embedded */ public function addItem(Varien_Object $item) { $index = count($this->_items); $item->_setEmbeddedIn($this->_root, $this->_path . '.' . $index); $itemId = $item->getIdFieldName() ? $this->_getItemKey($item->getId()) : NULL; if ($itemId !== NULL) { if (isset($this->_items[$itemId])) { throw new Exception('Item (' . get_class($item) . ') with the same id "' . $item->getId() . '" already exist'); } $this->_items[$itemId] = $item; } else { $this->_items[] = $item; } return $this; }