@@ -1544,7 +1544,11 @@ protected function _insertAttribute($object, $attribute, $value)
15441544 */
15451545 protected function _updateAttribute ($ object , $ attribute , $ valueId , $ value )
15461546 {
1547- return $ this ->_saveAttribute ($ object , $ attribute , $ value );
1547+ $ table = $ attribute ->getBackend ()->getTable ();
1548+ $ connection = $ this ->getConnection ();
1549+ $ connection ->update ($ table , ['value ' => $ this ->_prepareValueForSave ($ value , $ attribute )], 'value_id = ' . $ valueId );
1550+
1551+ return $ this ;
15481552 }
15491553
15501554 /**
@@ -1590,20 +1594,7 @@ protected function _processAttributeValues()
15901594 {
15911595 $ connection = $ this ->getConnection ();
15921596 foreach ($ this ->_attributeValuesToSave as $ table => $ data ) {
1593- $ insert = [];
1594- foreach ($ data as $ attributeData ) {
1595- $ whereValues = $ attributeData ;
1596- unset($ whereValues ['value ' ]);
1597- if ($ valueId = $ this ->checkExistingAttributeValue ($ table , $ attributeData )) {
1598- $ connection ->update ($ table , ['value ' => $ attributeData ['value ' ]], $ valueId );
1599- } else {
1600- $ insert [] = $ attributeData ;
1601- }
1602- }
1603-
1604- if (!empty ($ insert )) {
1605- $ connection ->insertArray ($ table , array_keys ($ insert [0 ]), $ insert );
1606- }
1597+ $ connection ->insertOnDuplicate ($ table , $ data , array_keys ($ data [0 ]));
16071598 }
16081599
16091600 foreach ($ this ->_attributeValuesToDelete as $ table => $ valueIds ) {
@@ -1617,27 +1608,6 @@ protected function _processAttributeValues()
16171608 return $ this ;
16181609 }
16191610
1620- /**
1621- * Checks for existing attribute record
1622- *
1623- * @param string $table
1624- * @param array $attributeData
1625- * @return string
1626- */
1627- protected function checkExistingAttributeValue (string $ table , array $ attributeData ): string
1628- {
1629- $ connection = $ this ->getConnection ();
1630- $ where = [];
1631- unset($ attributeData ['value ' ]);
1632-
1633- foreach ($ attributeData as $ key => $ val ) {
1634- $ where [] = sprintf ('%s = :%s ' , $ key , $ key );
1635- }
1636- $ select = $ connection ->select ()->from ($ table , 'value_id ' )->where (implode (' AND ' , $ where ));
1637-
1638- return $ connection ->fetchOne ($ select , $ attributeData );
1639- }
1640-
16411611 /**
16421612 * Prepare value for save
16431613 *
0 commit comments