public function testSearchById() { $brand = BrandQuery::create()->findOne(); if (null === $brand) { $brand = new \Thelia\Model\Brand(); $brand->setVisible(1); $brand->setTitle('foo'); $brand->save(); } $otherParameters = array("visible" => "*"); $this->baseTestSearchById($brand->getId(), $otherParameters); }
function createBrands($faker, $con) { echo "start creating brands\n"; $fileSystem = new \Symfony\Component\Filesystem\Filesystem(); $brands = array(); if (($handle = fopen(THELIA_ROOT . '/setup/import/brand.csv', "r")) !== FALSE) { $row = 0; while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { $row++; if ($row == 1) { continue; } $brand = new \Thelia\Model\Brand(); $brand->setVisible(1)->setPosition($row - 1)->setLocale('fr_FR')->setTitle(trim($data[0]))->setChapo($faker->text(20))->setDescription($faker->text(100))->setLocale('en_US')->setTitle(trim($data[0]))->setChapo($faker->text(20))->setDescription($faker->text(100))->save($con); $brands[trim($data[0])] = $brand; $images = explode(';', $data[1]); $logoId = null; foreach ($images as $image) { $image = trim($image); if (empty($image)) { continue; } $brandImage = new \Thelia\Model\BrandImage(); $brandImage->setBrandId($brand->getId())->setFile($image)->save($con); if ($logoId === null) { $logoId = $brandImage->getId(); } $fileSystem->copy(THELIA_ROOT . 'setup/import/images/' . $image, THELIA_ROOT . 'local/media/images/brand/' . $image, true); } if ($logoId !== null) { $brand->setLogoImageId($logoId); $brand->save($con); } } fclose($handle); } echo "brands created successfully\n"; return $brands; }