/**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     foreach ($this->data as $categoryReference => $data) {
         /** @var Channel $channel */
         $channel = $this->getReference($data['channel']);
         $entity = new RFMMetricCategory();
         $entity->setChannel($channel)->setCategoryType($data['categoryType'])->setCategoryIndex($data['categoryIndex'])->setMaxValue($data['maxValue'])->setMinValue($data['minValue']);
         $this->setReference($categoryReference, $entity);
         $manager->persist($entity);
     }
     $manager->flush();
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     foreach ($this->data as $value) {
         $entity = new RFMMetricCategory();
         $entity->setOwner($organization);
         /** @var Channel $channel */
         $channel = $this->getReference('default_channel');
         $value['channel'] = $channel->setData([RFMAwareInterface::RFM_STATE_KEY => true]);
         $this->setEntityPropertyValues($entity, $value, ['reference']);
         $this->setReference($value['reference'], $entity);
         $manager->persist($entity);
     }
     $manager->flush();
 }
 /**
  * @param Channel $channel
  *
  * @return RFMMetricCategory
  */
 protected function getCategory($channel)
 {
     $category = new RFMMetricCategory();
     $category->setChannel($channel);
     return $category;
 }
 /**
  * @param string $type
  *
  * @return RFMMetricCategory
  */
 protected function getCategory($type)
 {
     $category = new RFMMetricCategory();
     $category->setCategoryType($type);
     return $category;
 }
 /**
  * @param string $type
  * @param int $index
  * @param int $minValue
  * @param int $maxValue
  *
  * @return RFMMetricCategory
  */
 protected function getCategory($type, $index, $minValue, $maxValue)
 {
     $category = new RFMMetricCategory();
     $category->setCategoryType($type)->setCategoryIndex($index)->setMinValue($minValue)->setMaxValue($maxValue);
     return $category;
 }
 /**
  * @param ObjectManager $om
  */
 protected function persistDemoRFM(ObjectManager $om)
 {
     $rfmData = ['recency' => [['min' => null, 'max' => 7], ['min' => 7, 'max' => 30], ['min' => 30, 'max' => 90], ['min' => 90, 'max' => 365], ['min' => 365, 'max' => null]], 'frequency' => [['min' => 52, 'max' => null], ['min' => 12, 'max' => 52], ['min' => 4, 'max' => 12], ['min' => 2, 'max' => 4], ['min' => null, 'max' => 2]], 'monetary' => [['min' => 10000, 'max' => null], ['min' => 1000, 'max' => 10000], ['min' => 100, 'max' => 1000], ['min' => 10, 'max' => 100], ['min' => null, 'max' => 10]]];
     foreach ($rfmData as $type => $values) {
         foreach ($values as $idx => $limits) {
             $category = new RFMMetricCategory();
             $category->setCategoryIndex($idx + 1)->setChannel($this->dataChannel)->setCategoryType($type)->setMinValue($limits['min'])->setMaxValue($limits['max'])->setOwner($this->organization);
             $om->persist($category);
         }
     }
     $data = $this->dataChannel->getData();
     $data['rfm_enabled'] = true;
     $this->dataChannel->setData($data);
     $om->persist($this->dataChannel);
 }