protected function getTestGroup() { $group = new XLite\Module\CDev\ProductOptions\Model\OptionGroup(); $group->setProduct($this->getProduct()); $this->getProduct()->addOptionGroups($group); $group->map($this->testGroup); $option = new XLite\Module\CDev\ProductOptions\Model\Option(); $option->setGroup($group); $group->addOptions($option); $option->map($this->testOption); $option = new XLite\Module\CDev\ProductOptions\Model\Option(); $option->setGroup($group); $group->addOptions($option); $option->map($this->testOption); $option->setName('o2'); $option = new XLite\Module\CDev\ProductOptions\Model\Option(); $option->setGroup($group); $group->addOptions($option); $option->map($this->testOption); $option->setName('o3'); $s = new XLite\Module\CDev\ProductOptions\Model\OptionSurcharge(); $s->setOption($option); $s->setType('price'); $s->setModifier(10); $s->setModifierType('$'); $option->addSurcharges($s); $e = new XLite\Module\CDev\ProductOptions\Model\OptionException(); $e->setOption($option); $e->setExceptionId(\XLite\Core\Database::getRepo('XLite\\Module\\CDev\\ProductOptions\\Model\\OptionException')->getNextExceptionId()); $option->addExceptions($e); \XLite\Core\Database::getEM()->persist($group); \XLite\Core\Database::getEM()->flush(); return $group; }
protected function getTestGroups() { foreach ($this->testGroups as $data) { $group = new XLite\Module\CDev\ProductOptions\Model\OptionGroup(); $group->setProduct($this->getProduct()); $this->getProduct()->addOptionGroups($group); $group->map($data); foreach ($this->testOptions[$data['name']] as $opt) { $option = new XLite\Module\CDev\ProductOptions\Model\Option(); $option->setGroup($group); $group->addOptions($option); $option->map($opt); } \XLite\Core\Database::getEM()->persist($group); } $e = new XLite\Module\CDev\ProductOptions\Model\OptionException(); $e->setOption($this->getProduct()->getOptionGroups()->get(0)->getOptions()->get(0)); $e->setOption($this->getProduct()->getOptionGroups()->get(1)->getOptions()->get(1)); $e->setExceptionId(\XLite\Core\Database::getRepo('XLite\\Module\\CDev\\ProductOptions\\Model\\OptionException')->getNextExceptionId()); $this->getProduct()->getOptionGroups()->get(0)->getOptions()->get(0)->addExceptions($e); $this->getProduct()->getOptionGroups()->get(1)->getOptions()->get(1)->addExceptions($e); \XLite\Core\Database::getEM()->flush(); $e = new XLite\Module\CDev\ProductOptions\Model\OptionException(); $e->setOption($this->getProduct()->getOptionGroups()->get(0)->getOptions()->get(1)); $e->setOption($this->getProduct()->getOptionGroups()->get(1)->getOptions()->get(1)); $e->setExceptionId(\XLite\Core\Database::getRepo('XLite\\Module\\CDev\\ProductOptions\\Model\\OptionException')->getNextExceptionId()); $this->getProduct()->getOptionGroups()->get(0)->getOptions()->get(1)->addExceptions($e); $this->getProduct()->getOptionGroups()->get(1)->getOptions()->get(1)->addExceptions($e); \XLite\Core\Database::getEM()->flush(); }
/** * Save exception * * @param integer $eid Exception id * @param array $data Exception cell data * * @return void */ protected function saveException($eid, array $data) { foreach ($data as $groupId => $optionId) { if ($optionId) { $option = \XLite\Core\Database::getRepo('\\XLite\\Module\\CDev\\ProductOptions\\Model\\Option')->find($optionId); if ($option) { $exception = new \XLite\Module\CDev\ProductOptions\Model\OptionException(); $exception->setExceptionId($eid); $exception->setOption($option); $option->addExceptions($exception); \XLite\Core\Database::getEM()->persist($exception); } } } }