/**
  * @param Product $product
  * @return Product
  */
 public function saveProduct($product)
 {
     $this->getDb()->beginTransaction();
     try {
         if ($product->getId() == 0) {
             $this->getDb()->query("\n                    INSERT INTO product\n                    (model, sku, upc, location, quantity, stock_status_id, image, manufacturer_id, supplier_id, shipping,\n                    price, points, tax_class_id, date_available, weight, weight_class_id, length, width, height, \n                    length_class_id, subtract, minimum, sort_order, status, date_added, date_modified, viewed, user_id,\n                    afc_id, affiliate_commission, korean_name, supplier_url, image_description)\n                    VALUES (\n                        :model, :sku, :upc, :location, :quantity, :stockStatusId, :image, :manufacturerId, :supplierId, \n                        :shipping, :price, :points, 0, :dateAvailable, :weight, :weightClassId, :length, :width, :height, \n                        :lengthClassId, :subtract, :minimum, :sortOrder, :status, NOW(), NOW(), 0, :userId, :afcId, \n                        :affiliateCommission, :koreanName, :supplierUrl, :imageDescription\n                    )\n                    ", [':model' => $product->getModel(), ':sku' => $product->getSku(), ':upc' => $product->getUpc(), ':location' => $product->getLocation(), ':quantity' => $product->getQuantity(), ':stockStatusId' => $product->getStockStatusId(), ':image' => $product->getImagePath(), ':manufacturerId' => $product->getManufacturer()->getId(), ':supplierId' => $product->getSupplier()->getId(), ':shipping' => $product->getShipping(), ':price' => $product->getPrice(), ':points' => $product->getPoints(), ':dateAvailable' => $product->getDateAvailable(), ':weight' => $product->getWeight()->getWeight(), ':weightClassId' => $product->getWeight()->getUnit()->getId(), ':length' => $product->getDimension()->getLength(), ':width' => $product->getDimension()->getWidth(), ':height' => $product->getDimension()->getHeight(), ':lengthClassId' => $product->getDimension()->getUnit()->getId(), ':subtract' => $product->getSubtract(), ':minimum' => $product->getMinimum(), ':sortOrder' => $product->getSortOrder(), ':status' => $product->getStatus(), ':userId' => $product->getUserId(), ':afcId' => $product->getAfcId(), ':affiliateCommission' => $product->getAffiliateCommission(), ':koreanName' => $product->getKoreanName(), ':supplierUrl' => $product->getSupplierUrl(), ':imageDescription' => $product->getImageDescription()]);
             $product->setId($this->getDb()->getLastId());
         } else {
             $this->getDb()->query("\n                    UPDATE product\n                    SET\n                        model = :model,\n                        sku = :sku,\n                        upc = :upc,\n                        location = :location,\n                        minimum = :minimum,\n                        subtract = :subtract,\n                        stock_status_id = :stockStatusId,\n                        date_available = :dateAvailable,\n                        manufacturer_id = :manufacturerId,\n                        supplier_id = :supplierId,\n                        shipping = :shipping,\n                        price = :price,\n                        points = :points,\n                        weight = :weight,\n                        weight_class_id = :weightClassId,\n                        length = :length,\n                        width = :width,\n                        height = :height,\n                        length_class_id = :lengthClassId,\n                        status = :status,\n                        sort_order = :sortOrder,\n                        affiliate_commission = :affiliateCommission,\n                        image = :image,\n                        date_modified = NOW(),\n                        korean_name = :koreanName,\n                        supplier_url = :supplierUrl,\n                        image_description = :imageDescription\n                    WHERE product_id = :productId\n                    ", array(':model' => $product->getModel(), ':sku' => $product->getSku(), ':upc' => $product->getUpc(), ':location' => $product->getLocation(), ':minimum' => $product->getMinimum(), ':subtract' => $product->getSubtract(), ':stockStatusId' => $product->getStockStatusId(), ':dateAvailable' => $product->getDateAvailable(), ':manufacturerId' => $product->getManufacturer()->getId(), ':supplierId' => $product->getSupplier()->getId(), ':shipping' => $product->getShipping(), ':price' => $product->getPrice(), ':points' => $product->getPoints(), ':weight' => $product->getWeight()->getWeight(), ':weightClassId' => $product->getWeight()->getUnit()->getId(), ':length' => $product->getDimension()->getLength(), ':width' => $product->getDimension()->getWidth(), ':height' => $product->getDimension()->getHeight(), ':lengthClassId' => $product->getDimension()->getUnit()->getId(), ':status' => $product->getStatus(), ':sortOrder' => $product->getSortOrder(), ':affiliateCommission' => $product->getAffiliateCommission(), ':image' => $product->getImagePath(), ':productId' => $product->getId(), ':koreanName' => $product->getKoreanName(), ':supplierUrl' => $product->getSupplierUrl(), ':imageDescription' => $product->getImageDescription()));
         }
         $this->saveDescription($product);
         $this->saveStores($product);
         $this->saveAttributes($product);
         $this->saveOptions($product);
         $this->saveDiscounts($product);
         $this->saveSpecials($product);
         $this->saveImages($product);
         $this->saveDownloads($product);
         $this->saveCategories($product);
         $this->saveRelated($product);
         $this->saveRewards($product);
         $this->saveLayouts($product);
         $this->saveTags($product);
         $this->saveUrlAliases($product);
         $this->saveWKAuction($product->getId());
         $this->getCache()->deleteAll('/^product/');
         $this->getDb()->commitTransaction();
     } catch (\Exception $e) {
         $this->getLogger()->write($e->getMessage());
         $this->getLogger()->write($e->getTraceAsString());
         $this->getDb()->rollbackTransaction();
     }
     return $product;
 }