@@ -1544,7 +1544,11 @@ protected function _insertAttribute($object, $attribute, $value)
1544
1544
*/
1545
1545
protected function _updateAttribute ($ object , $ attribute , $ valueId , $ value )
1546
1546
{
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 ;
1548
1552
}
1549
1553
1550
1554
/**
@@ -1590,20 +1594,7 @@ protected function _processAttributeValues()
1590
1594
{
1591
1595
$ connection = $ this ->getConnection ();
1592
1596
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 ]));
1607
1598
}
1608
1599
1609
1600
foreach ($ this ->_attributeValuesToDelete as $ table => $ valueIds ) {
@@ -1617,27 +1608,6 @@ protected function _processAttributeValues()
1617
1608
return $ this ;
1618
1609
}
1619
1610
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
-
1641
1611
/**
1642
1612
* Prepare value for save
1643
1613
*
0 commit comments