public function beforeValidate()
{
foreach ($this->getTypeAttributes() as $attribute) {
if ($attribute->isType(Attribute::TYPE_CHECKBOX)) {
continue;
}
if ($attribute->isRequired() && (!isset($this->_typeAttributes[$attribute->id]) || '' === $this->_typeAttributes[$attribute->id])) {
$this->addError($attribute->title, Yii::t("StoreModule.store", "{title} attribute is required", ['title' => $attribute->title]));
}
}
if (!$this->isInStock()) {
$this->setEmptyQuantity();
}
return parent::beforeValidate();
}