/** * {@inheritDoc} */ public function load(ObjectManager $objectManager) { $accounts = $this->getAccountsWithoutPartners($objectManager, count(self::$fixtureConditions)); if (!$accounts) { return; } $users = $objectManager->getRepository('OroUserBundle:User')->findAll(); $statuses = $objectManager->getRepository('OroCRMPartnerBundle:PartnerStatus')->findAll(); $usersCount = count($users); $statusesCount = count($statuses); foreach ($accounts as $index => $account) { $partner = new Partner(); $partner->setAccount($account); $partner->setOwner($users[rand(0, $usersCount - 1)]); $partner->setStatus($statuses[rand(0, $statusesCount - 1)]); $partner->setPartnerCondition(self::$fixtureConditions[$index]); $objectManager->persist($partner); } $objectManager->flush(); }