/**
  * Saves an product into the database.
  *
  * @param \Soundify\Domain\Product product The product to save
  */
 public function save(Product $product)
 {
     $productData = array('product_name' => $product->getName(), 'product_short_desc' => $product->getShortDescription(), 'product_long_desc' => $product->getLongDescription(), 'product_price' => $product->getPrice(), 'product_category' => $product->getCategory(), 'product_image' => $product->getImage());
     if ($product->getId()) {
         // The article has already been saved : update it
         //$this->addImage($productData['product_image']);
         //$productData['product_image'] = $productData['product_image']['name'];
         $this->getDb()->update('product', $productData, array('product_id' => $product->getId()));
     } else {
         // The article has never been saved : insert it
         $this->addImage($productData['product_image']);
         $productData['product_image'] = $productData['product_image']->getClientOriginalName();
         $this->getDb()->insert('product', $productData);
         // Get the id of the newly created product and set it on the entity.
         $id = $this->getDb()->lastInsertId();
         $product->setId($id);
     }
 }