public function setUp() { parent::setUp(); $this->product = Product::getNewInstance($this->rootCategory, 'test'); $this->product->save(); $this->group = ProductFileGroup::getNewInstance($this->product); $this->group->save(); // create temporary file file_put_contents($this->tmpFilePath, $this->fileBody); }
private function save(ProductFileGroup $fileGroup) { $validator = $this->buildValidator(); if ($validator->isValid()) { foreach ($this->application->getLanguageArray(true) as $lang) { if ($this->request->isValueSet('name_' . $lang)) { $fileGroup->setValueByLang('name', $lang, $this->request->get('name_' . $lang)); } } $fileGroup->save(); return new JSONResponse(array('status' => "success", 'ID' => $fileGroup->getID())); } else { return new JSONResponse(array('status' => "failure", 'errors' => $validator->getErrorList())); } }