Example #1
0
 /**
  * @param \opus\ecom\Basket $basket
  * @return void
  */
 public function save(Basket $basket)
 {
     $identifier = $this->getIdentifier($basket->getSession()->getId());
     $items = $basket->getItems();
     $sessionData = serialize($items);
     $command = $this->db->createCommand();
     if (empty($items) && true === $this->deleteIfEmpty) {
         $command->delete($this->table, [$this->idField => $identifier]);
     } else {
         $command->setSql("\n                REPLACE {{{$this->table}}}\n                SET\n                    {{{$this->dataField}}} = :val,\n                    {{{$this->idField}}} = :id\n            ")->bindValues([':id' => $identifier, ':val' => $sessionData]);
     }
     $command->execute();
 }