protected function createProduct(array $data) { $sm = $this->getServiceLocator(); $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new \Store\Model\Product()); $tableGateway = new \Zend\Db\TableGateway\TableGateway('product', $dbAdapter, null, $resultSetPrototype); $product = new Product(); $product->exchangeArray($data); $productTable = new ProductTable($tableGateway); $productTable->saveProduct($product); return true; }
public function processAction() { // var_dump($_POST); $upload = new Product(); // var_dump($this->params()->fromPost('name',null)); $uploadFile = $this->params()->fromFiles('imageupload'); //var_dump($uploadFile); // $form = $this->getServiceLocator()->get('ProductForm'); $uploadPath = $this->getFileUploadLocation(); echo "<br>" . $uploadPath; // Save Uploaded file $adapter = new \Zend\File\Transfer\Adapter\Http(); $adapter->setDestination($uploadPath); echo "<br>" . $uploadFile['name']; if ($adapter->receive($uploadFile['name'])) { $exchange_data = array(); $exchange_data['name'] = $this->params()->fromPost('name', null); $exchange_data['filename'] = $uploadFile['name']; $exchange_data['price'] = $this->params()->fromPost('price', null); $exchange_data['description'] = $this->params()->fromPost('description', null); // var_dump($exchange_data); $upload->exchangeArray($exchange_data); } // Create product $this->createProduct($upload); /* return $this->redirect()->toRoute(NULL, array( 'controller' => 'product', 'action' => 'confirm' )); */ return false; }