Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
             $content->save();
             $contentId = $content->getId();
             $contentIdList[] = $contentId;
             $image = new \Thelia\Model\ContentImage();
             $image->setContentId($contentId);
             generate_image($image, 'content', $contentId);
             $document = new \Thelia\Model\ContentDocument();
             $document->setContentId($contentId);
             generate_document($document, 'content', $contentId);
         }
     }
 }
 echo "Creating brands\n";
 $brandIdList = [];
 for ($k = 0; $k < 10; $k++) {
     $brand = new Thelia\Model\Brand();
     $brand->setVisible(1);
     $brand->setPosition($k + 1);
     setI18n($brand);
     $brand->save();
     $brandId = $brand->getId();
     $brandIdList[] = $brandId;
     $image = new \Thelia\Model\BrandImage();
     $image->setBrandId($brandId);
     generate_image($image, 'brand', $brandId);
     $document = new \Thelia\Model\BrandDocument();
     $document->setBrandId($brandId);
     generate_document($document, 'brand', $brandId);
 }
 echo "Creating categories and products\n";
 //categories and products
Exemplo n.º 3
0
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;
}