Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $now = new \DateTime();
     foreach ($this->data as $priceListData) {
         $priceList = new PriceList();
         $priceList->setName($priceListData['name'])->setDefault($priceListData['default'])->setCurrencies(['USD'])->setCreatedAt($now)->setUpdatedAt($now);
         foreach ($priceListData['customers'] as $customerReference) {
             /** @var Customer $customer */
             $customer = $this->getReference($customerReference);
             $priceList->addCustomer($customer);
         }
         foreach ($priceListData['groups'] as $customerGroupReference) {
             /** @var CustomerGroup $customerGroup */
             $customerGroup = $this->getReference($customerGroupReference);
             $priceList->addCustomerGroup($customerGroup);
         }
         foreach ($priceListData['websites'] as $websiteReference) {
             /** @var Website $website */
             $website = $this->getReference($websiteReference);
             $priceList->addWebsite($website);
         }
         foreach ($priceListData['currencies'] as $currencyCode) {
             $priceList->addCurrencyByCode($currencyCode);
         }
         $manager->persist($priceList);
         $this->setReference($priceListData['reference'], $priceList);
     }
     $manager->flush();
 }