public function addItem(CartItemInterface $item) { if ($item->getCartItemId() == null) { $this->items[] = $item; } else { $this->items[$item->getCartItemId()] = $item; } return $this; }
public function persist(CartItemInterface $item) { if ($item->getCartItemId() > 0) { $where = new Where(); $where->equalTo($this->itemIdField, $item->getCartItemId()); $this->update($item, $where, $this->tableName); } else { $result = $this->insert($item, $this->tableName); $item->setCartItemId($result->getGeneratedValue()); } return $item; }