/** * Get attribute value data * * @param array $data Import row data * @param \XLite\Model\Attribute $attribute Attribute object * * @return array */ protected function getAttributeValueData($data, $attribute) { $option = \XLite\Core\Database::getRepo('XLite\\Model\\AttributeOption')->findOneByNameAndAttribute($data['value'], $attribute); if (!$option) { $option = new \XLite\Model\AttributeOption(); $option->setAttribute($attribute); $option->setName($data['value']); \XLite\Core\Database::getEM()->persist($option); } return array('attribute_option' => $option); }
/** * Create attribute option * * @param string $value Option name * * @return \XLite\Model\AttributeOption */ protected function createAttributeOption($value) { $attributeOption = new \XLite\Model\AttributeOption(); $attributeOption->setAttribute($this); $attributeOption->setName($value); \XLite\Core\Database::getEM()->persist($attributeOption); return $attributeOption; }