/**
  * @param Mage_Eav_Model_Entity_Type $object
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param mixed $value
  * @return $this
  * @throws Mage_Core_Exception
  */
 protected function _saveAttribute($object, $attribute, $value)
 {
     $table = $attribute->getBackend()->getTable();
     if (!isset($this->_attributeValuesToSave[$table])) {
         $this->_attributeValuesToSave[$table] = array();
     }
     $entityIdField = $attribute->getBackend()->getEntityIdField();
     $data = array('entity_type_id' => $object->getEntityTypeId(), $entityIdField => $object->getId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute));
     $this->_attributeValuesToSave[$table][] = $data;
     $this->_saveEntityData($object);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Validate attribute set
  *
  * @param array $data
  * @param Mage_Eav_Model_Entity_Type $productEntity
  * @return bool
  */
 protected function _validateAttributeSet($data, $productEntity)
 {
     if ($this->_isUpdate()) {
         return true;
     }
     if (!isset($data['attribute_set_id']) || empty($data['attribute_set_id'])) {
         $this->_critical('Missing "attribute_set_id" in request.', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
     }
     /** @var $attributeSet Mage_Eav_Model_Entity_Attribute_Set */
     $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($data['attribute_set_id']);
     if (!$attributeSet->getId() || $productEntity->getEntityTypeId() != $attributeSet->getEntityTypeId()) {
         $this->_critical('Invalid attribute set.', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
     }
 }