@@ -1669,7 +1669,6 @@ protected function _deleteAttributes($object, $table, $info)
16691669 */
16701670 public function saveAttribute (DataObject $ object , $ attributeCode )
16711671 {
1672- $ updateValue = 0 ;
16731672 $ attribute = $ this ->getAttribute ($ attributeCode );
16741673 $ backend = $ attribute ->getBackend ();
16751674 $ table = $ backend ->getTable ();
@@ -1700,15 +1699,10 @@ public function saveAttribute(DataObject $object, $attributeCode)
17001699 $ this ->_insertAttribute ($ object , $ attribute , $ newValue );
17011700 } elseif ($ origValueId !== false && $ newValue !== null ) {
17021701 $ this ->_updateAttribute ($ object , $ attribute , $ origValueId , $ newValue );
1703- $ updateValue = 1 ;
17041702 } elseif ($ origValueId !== false && $ newValue === null && $ origValue !== null ) {
17051703 $ connection ->delete ($ table , $ where );
17061704 }
1707- if ($ updateValue === 1 && $ origValue === $ newValue ) {
1708- $ this ->_updateAttributeValues ($ attribute , $ origValueId );
1709- } else {
1710- $ this ->_processAttributeValues ();
1711- }
1705+ $ this ->_processAttributeValues ();
17121706 $ connection ->commit ();
17131707 } catch (\Exception $ e ) {
17141708 $ connection ->rollBack ();
@@ -2017,36 +2011,4 @@ protected function loadAttributesForObject($attributes, $object = null)
20172011 }
20182012 }
20192013 }
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- }
20522014}
0 commit comments