public function create(Product $product, $price, $duration = null)
 {
     $ps = new PriceSolution();
     $ps->setPrice($price);
     $ps->setProduct($product);
     $ps->setMonthDuration($duration);
     $this->om->persist($ps);
     $this->om->flush();
     return $ps;
 }
예제 #2
0
 private function createSupportCreditsProducts()
 {
     $this->log('Creating support credits products...');
     $pack20 = $this->productRepo->findOneByCode('SUPPORT_CREDITS_PACK_20');
     if (is_null($pack20)) {
         $pack20 = new Product();
         $pack20->setCode('SUPPORT_CREDITS_PACK_20');
         $pack20->setType('SUPPORT_CREDITS');
         $details = array('name' => 'Pack 20', 'nb_credits' => 20, 'nb_hours' => 4, 'saving' => 0);
         $pack20->setDetails($details);
         $pack20->setIsActivated(true);
         $priceSolution = new PriceSolution();
         $priceSolution->setPrice(250);
         $priceSolution->setProduct($pack20);
         $this->om->persist($priceSolution);
         $pack20->addPriceSolution($priceSolution);
         $this->om->persist($pack20);
     }
     $pack50 = $this->productRepo->findOneByCode('SUPPORT_CREDITS_PACK_50');
     if (is_null($pack50)) {
         $pack50 = new Product();
         $pack50->setCode('SUPPORT_CREDITS_PACK_50');
         $pack50->setType('SUPPORT_CREDITS');
         $details = array('name' => 'Pack 50', 'nb_credits' => 50, 'nb_hours' => 10, 'saving' => 50);
         $pack50->setDetails($details);
         $pack50->setIsActivated(true);
         $priceSolution = new PriceSolution();
         $priceSolution->setPrice(575);
         $priceSolution->setProduct($pack50);
         $this->om->persist($priceSolution);
         $pack50->addPriceSolution($priceSolution);
         $this->om->persist($pack50);
     }
     $pack100 = $this->productRepo->findOneByCode('SUPPORT_CREDITS_PACK_100');
     if (is_null($pack100)) {
         $pack100 = new Product();
         $pack100->setCode('SUPPORT_CREDITS_PACK_100');
         $pack100->setType('SUPPORT_CREDITS');
         $details = array('name' => 'Pack 100', 'nb_credits' => 100, 'nb_hours' => 20, 'saving' => 250);
         $pack100->setDetails($details);
         $pack100->setIsActivated(true);
         $priceSolution = new PriceSolution();
         $priceSolution->setPrice(1000);
         $priceSolution->setProduct($pack100);
         $this->om->persist($priceSolution);
         $pack50->addPriceSolution($priceSolution);
         $this->om->persist($pack100);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $data = array(array('code' => 'SUPPORT_CREDITS_PACK_20', 'type' => 'SUPPORT_CREDITS', 'details' => array('name' => 'Pack 20', 'nb_credits' => 20, 'nb_hours' => 4, 'saving' => 0), 'pricing' => 250), array('code' => 'SUPPORT_CREDITS_PACK_50', 'type' => 'SUPPORT_CREDITS', 'details' => array('name' => 'Pack 50', 'nb_credits' => 50, 'nb_hours' => 10, 'saving' => 50), 'pricing' => 575), array('code' => 'SUPPORT_CREDITS_PACK_100', 'type' => 'SUPPORT_CREDITS', 'details' => array('name' => 'Pack 100', 'nb_credits' => 100, 'nb_hours' => 20, 'saving' => 250), 'pricing' => 1000));
     foreach ($data as $info) {
         $product = new Product();
         $product->setCode($info['code']);
         $product->setType($info['type']);
         $product->setDetails($info['details']);
         $product->setIsActivated(true);
         $priceSolution = new PriceSolution();
         $priceSolution->setPrice($info['pricing']);
         $priceSolution->setProduct($product);
         $manager->persist($priceSolution);
         $product->addPriceSolution($priceSolution);
         $manager->persist($product);
     }
     $manager->flush();
 }