| 
					
				 | 
			
			
				@@ -0,0 +1,41 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<?php 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+namespace App\DataFixtures; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Entity\Product; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Doctrine\Bundle\FixturesBundle\Fixture; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Doctrine\Common\DataFixtures\DependentFixtureInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Doctrine\Common\Persistence\ObjectManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class ProductFixture extends Fixture implements DependentFixtureInterface { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * Load data fixtures with the passed EntityManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * @param ObjectManager $manager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public function load(ObjectManager $manager) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for ($i = 0; $i < 7 * ZCategoryFixture::NCAT; $i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $prod = new Product(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $prod->setName("product-{$i}"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $prod->setPrice(mt_rand(100 * $i, 100 * ($i + 1)) / 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $catId = "category-" . $i % ZCategoryFixture::NCAT; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $catReference = $this->getReference($catId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $prod->setCategory($catReference); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $manager->persist($prod); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $manager->flush(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * Override the alphabetical ordering of fixtures loading. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * @return array 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public function getDependencies() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ZCategoryFixture::class, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |