public function save(Product $product) { $data = array('upc_bar_code' => $product->getUpcBarCode(), 'model' => $product->getModel(), 'brand' => $product->getBrand(), 'category' => $product->getCategory(), 'part_no' => $product->getPartNo(), 'price' => $product->getPrice(), 'iva' => $product->getIva(), 'qty_low' => $product->getQtyLow(), 'qty_buy' => $product->getQtyBuy(), 'description' => $product->getDescription(), 'specification_file' => $product->getSpecificationFile(), 'image1' => $product->getImage1(), 'image2' => $product->getImage2(), 'image3' => $product->getImage3(), 'image4' => $product->getImage4(), 'image5' => $product->getImage5(), 'image6' => $product->getImage6(), 'manual_file' => $product->getManualFile(), 'video' => $product->getVideo(), 'status' => $product->getStatus(), 'register_date' => date("Y-m-d H:i:s", time()), 'update_date' => date("Y-m-d H:i:s", time())); $id = (int) $product->getId(); $params = array(); $params['table'] = $this->tableGateway->getTableName(); $params['operation'] = 1; $params['data'] = json_encode($data); if ($id == 0) { $this->tableGateway->insert($data); $id = $this->tableGateway->getLastInsertValue(); if ($id) { $params['id'] = $id; $this->featureSet->getEventManager()->trigger("log.save", $this, $params); return $id; } else { return false; } } else { if ($this->get($id)) { $params['id'] = $id; $params['operation'] = 2; $this->featureSet->getEventManager()->trigger("log.save", $this, $params); $this->tableGateway->update($data, array('id' => $id)); return $id; } else { return false; } } }