/** * Sets specification attribute value by mapping product, specification field, and * assigned value to one record (atomic item) * * @param iEavSpecification $specification Specification item value */ public function setAttribute(iEavSpecification $newSpecification) { $specField = $newSpecification->getFieldInstance(); $itemClass = $specField->getSelectValueClass(); if ($this->owner->isExistingRecord() && isset($this->attributes[$newSpecification->getFieldInstance()->getID()]) && ($itemClass == $specField->getSpecificationFieldClass() && $newSpecification->getValue()->isModified())) { // Delete old value ActiveRecord::deleteByID($itemClass, $this->attributes[$specField->getID()]->getID()); // And create new $this->attributes[$specField->getID()] = call_user_func_array(array($itemClass, 'getNewInstance'), array($this->owner, $specField, $newSpecification->getValue()->get())); } else { $this->attributes[$specField->getID()] = $newSpecification; } unset($this->removedAttributes[$specField->getID()]); }