Пример #1
0
 /**
  * Import 'options' value
  *
  * @param \XLite\Model\Attribute $model  Attribute
  * @param array                  $value  Value
  * @param array                  $column Column info
  *
  * @return void
  */
 protected function importOptionsColumn(\XLite\Model\Attribute $model, array $value, array $column)
 {
     if ($value) {
         foreach ($value as $index => $val) {
             $option = $model->getAttributeOptions()->get($index);
             if (!$option) {
                 $option = new \XLite\Model\AttributeOption();
                 $option->setAttribute($model);
                 $model->getAttributeOptions()->add($option);
                 \XLite\Core\Database::getEM()->persist($option);
             }
             $this->updateModelTranslations($option, $val);
         }
         while (count($model->getAttributeOptions()) > count($value)) {
             $option = $model->getAttributeOptions()->last();
             \XLite\Core\Database::getRepo('\\XLite\\Model\\AttributeOption')->delete($option, false);
             $model->getAttributeOptions()->removeElement($option);
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getAttributeOptions()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAttributeOptions', array());
     return parent::getAttributeOptions();
 }