public function addItem(CartItemInterface $item) { if ($item->getCartItemId() == null) { $this->items[] = $item; } else { $this->items[$item->getCartItemId()] = $item; } return $this; }
public function addItemToCart(CartItemInterface $item, CartInterface $cart = null) { if ($cart === null) { $cart = $this->getSessionCart(true); } $item->setCartId($cart->getCartId())->setAddedTime(new \DateTime()); $this->itemMapper->persist($item); $this->persistCartItemChildren($item->getItems(), $item, $cart); $cart->addItem($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; }