@@ -1669,7 +1669,6 @@ protected function _deleteAttributes($object, $table, $info)
1669
1669
*/
1670
1670
public function saveAttribute (DataObject $ object , $ attributeCode )
1671
1671
{
1672
- $ updateValue = 0 ;
1673
1672
$ attribute = $ this ->getAttribute ($ attributeCode );
1674
1673
$ backend = $ attribute ->getBackend ();
1675
1674
$ table = $ backend ->getTable ();
@@ -1700,15 +1699,10 @@ public function saveAttribute(DataObject $object, $attributeCode)
1700
1699
$ this ->_insertAttribute ($ object , $ attribute , $ newValue );
1701
1700
} elseif ($ origValueId !== false && $ newValue !== null ) {
1702
1701
$ this ->_updateAttribute ($ object , $ attribute , $ origValueId , $ newValue );
1703
- $ updateValue = 1 ;
1704
1702
} elseif ($ origValueId !== false && $ newValue === null && $ origValue !== null ) {
1705
1703
$ connection ->delete ($ table , $ where );
1706
1704
}
1707
- if ($ updateValue === 1 && $ origValue === $ newValue ) {
1708
- $ this ->_updateAttributeValues ($ attribute , $ origValueId );
1709
- } else {
1710
- $ this ->_processAttributeValues ();
1711
- }
1705
+ $ this ->_processAttributeValues ();
1712
1706
$ connection ->commit ();
1713
1707
} catch (\Exception $ e ) {
1714
1708
$ connection ->rollBack ();
@@ -2017,36 +2011,4 @@ protected function loadAttributesForObject($attributes, $object = null)
2017
2011
}
2018
2012
}
2019
2013
}
2020
-
2021
- /**
2022
- * Update entity attribute values
2023
- *
2024
- * @param AbstractAttribute $attribute
2025
- * @param mixed $valueId
2026
- * @return $this
2027
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
2028
- */
2029
- private function _updateAttributeValues (AbstractAttribute $ attribute , mixed $ valueId ): static
2030
- {
2031
- $ connection = $ this ->getConnection ();
2032
- foreach ($ this ->_attributeValuesToSave as $ table => $ data ) {
2033
- foreach ($ data as $ columnValue ) {
2034
- $ connection ->update (
2035
- $ table ,
2036
- ['value ' => $ this ->_prepareValueForSave ($ columnValue ['value ' ], $ attribute )],
2037
- sprintf ('%s=%d ' , $ connection ->quoteIdentifier ('value_id ' ), $ valueId )
2038
- );
2039
- }
2040
- }
2041
-
2042
- foreach ($ this ->_attributeValuesToDelete as $ table => $ valueIds ) {
2043
- $ connection ->delete ($ table , ['value_id IN (?) ' => $ valueIds ]);
2044
- }
2045
-
2046
- // reset data arrays
2047
- $ this ->_attributeValuesToSave = [];
2048
- $ this ->_attributeValuesToDelete = [];
2049
-
2050
- return $ this ;
2051
- }
2052
2014
}
0 commit comments