/**
  * Update entity attribute value
  *
  * @param   Varien_Object $object
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   mixed $valueId
  * @param   mixed $value
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _updateAttribute($object, $attribute, $valueId, $value)
 {
     /**
      * If we work in single store mode all values should be saved just
      * for default store id
      * In this case we clear all not default values
      */
     if (AO::app()->isSingleStoreMode()) {
         $this->_getWriteAdapter()->delete($attribute->getBackend()->getTable(), $this->_getWriteAdapter()->quoteInto('attribute_id=?', $attribute->getId()) . $this->_getWriteAdapter()->quoteInto(' AND entity_id=?', $object->getId()) . $this->_getWriteAdapter()->quoteInto(' AND store_id!=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID));
     }
     /**
      * Update attribute value for store
      */
     if ($attribute->isScopeStore()) {
         $this->_updateAttributeForStore($object, $attribute, $value, $object->getStoreId());
     } elseif ($attribute->isScopeWebsite()) {
         if ($object->getStoreId() == 0) {
             $this->_updateAttributeForStore($object, $attribute, $value, $object->getStoreId());
         } else {
             if (is_array($object->getWebsiteStoreIds())) {
                 foreach ($object->getWebsiteStoreIds() as $storeId) {
                     $this->_updateAttributeForStore($object, $attribute, $value, $storeId);
                 }
             }
         }
     } else {
         $this->_getWriteAdapter()->update($attribute->getBackend()->getTable(), array('value' => $this->_prepareValueForSave($value, $attribute)), 'value_id=' . (int) $valueId);
     }
     return $this;
 }
예제 #2
0
 /**
  * Update entity attribute value
  *
  * @param   Varien_Object $object
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   mixed $valueId
  * @param   mixed $value
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _updateAttribute($object, $attribute, $valueId, $value)
 {
     /**
      * Update attribute value for store
      */
     if ($attribute->isScopeStore()) {
         $this->_updateAttributeForStore($object, $attribute, $value, $object->getStoreId());
     } elseif ($attribute->isScopeWebsite()) {
         if ($object->getStoreId() == 0) {
             $this->_updateAttributeForStore($object, $attribute, $value, $object->getStoreId());
         } else {
             if (is_array($object->getStoreIds())) {
                 foreach ($object->getStoreIds() as $storeId) {
                     $this->_updateAttributeForStore($object, $attribute, $value, $storeId);
                 }
             }
         }
     } else {
         $this->_getWriteAdapter()->update($attribute->getBackend()->getTable(), array('value' => $value), 'value_id=' . (int) $valueId);
     }
     return $this;
 }