public function beforeValidate()
{
if ($this->attribute_option_id) {
$option = AttributeOption::model()->findByPk($this->attribute_option_id);
$this->attribute_value = $option ? $option->value : null;
}
if (!$this->attribute_value) {
$this->addErrors(['attribute_value' => Yii::t('StoreModule.store', 'You must specify the attribute value')]);
}
return parent::beforeValidate();
}