@@ -1021,6 +1021,8 @@ public function load($object, $entityId, $attributes = [])
1021
1021
protected function loadAttributesMetadata ($ attributes )
1022
1022
{
1023
1023
$ this ->loadAttributesForObject ($ attributes );
1024
+
1025
+ return $ this ;
1024
1026
}
1025
1027
1026
1028
/**
@@ -1433,8 +1435,10 @@ protected function _processSaveData($saveData)
1433
1435
$ insertEntity = true ;
1434
1436
$ entityTable = $ this ->getEntityTable ();
1435
1437
$ entityIdField = $ this ->getEntityIdField ();
1438
+ // phpstan:ignore "Undefined variable"
1436
1439
$ entityId = $ newObject ->getId ();
1437
1440
1441
+ // phpstan:ignore "Undefined variable"
1438
1442
unset($ entityRow [$ entityIdField ]);
1439
1443
if (!empty ($ entityId ) && is_numeric ($ entityId )) {
1440
1444
$ bind = ['entity_id ' => $ entityId ];
@@ -1450,6 +1454,7 @@ protected function _processSaveData($saveData)
1450
1454
/**
1451
1455
* Process base row
1452
1456
*/
1457
+ // phpstan:ignore "Undefined variable"
1453
1458
$ entityObject = new DataObject ($ entityRow );
1454
1459
$ entityRow = $ this ->_prepareDataForTable ($ entityObject , $ entityTable );
1455
1460
if ($ insertEntity ) {
@@ -1460,6 +1465,7 @@ protected function _processSaveData($saveData)
1460
1465
$ connection ->insert ($ entityTable , $ entityRow );
1461
1466
$ entityId = $ connection ->lastInsertId ($ entityTable );
1462
1467
}
1468
+ // phpstan:ignore "Undefined variable"
1463
1469
$ newObject ->setId ($ entityId );
1464
1470
} else {
1465
1471
$ where = sprintf ('%s=%d ' , $ connection ->quoteIdentifier ($ entityIdField ), $ entityId );
@@ -1472,6 +1478,7 @@ protected function _processSaveData($saveData)
1472
1478
if (!empty ($ insert )) {
1473
1479
foreach ($ insert as $ attributeId => $ value ) {
1474
1480
$ attribute = $ this ->getAttribute ($ attributeId );
1481
+ // phpstan:ignore "Undefined variable"
1475
1482
$ this ->_insertAttribute ($ newObject , $ attribute , $ value );
1476
1483
}
1477
1484
}
@@ -1482,6 +1489,7 @@ protected function _processSaveData($saveData)
1482
1489
if (!empty ($ update )) {
1483
1490
foreach ($ update as $ attributeId => $ v ) {
1484
1491
$ attribute = $ this ->getAttribute ($ attributeId );
1492
+ // phpstan:ignore "Undefined variable"
1485
1493
$ this ->_updateAttribute ($ newObject , $ attribute , $ v ['value_id ' ], $ v ['value ' ]);
1486
1494
}
1487
1495
}
@@ -1491,12 +1499,14 @@ protected function _processSaveData($saveData)
1491
1499
*/
1492
1500
if (!empty ($ delete )) {
1493
1501
foreach ($ delete as $ table => $ values ) {
1502
+ // phpstan:ignore "Undefined variable"
1494
1503
$ this ->_deleteAttributes ($ newObject , $ table , $ values );
1495
1504
}
1496
1505
}
1497
1506
1498
1507
$ this ->_processAttributeValues ();
1499
1508
1509
+ // phpstan:ignore "Undefined variable"
1500
1510
$ newObject ->isObjectNew (false );
1501
1511
1502
1512
return $ this ;
@@ -1573,7 +1583,7 @@ protected function _processAttributeValues()
1573
1583
{
1574
1584
$ connection = $ this ->getConnection ();
1575
1585
foreach ($ this ->_attributeValuesToSave as $ table => $ data ) {
1576
- $ connection ->insertOnDuplicate ($ table , $ data , [ ' value ' ] );
1586
+ $ connection ->insertOnDuplicate ($ table , $ data , array_keys ( $ data [ 0 ]) );
1577
1587
}
1578
1588
1579
1589
foreach ($ this ->_attributeValuesToDelete as $ table => $ valueIds ) {
@@ -1607,7 +1617,9 @@ protected function _prepareValueForSave($value, AbstractAttribute $attribute)
1607
1617
self ::$ _attributeBackendTables [$ backendTable ] = $ this ->getConnection ()->describeTable ($ backendTable );
1608
1618
}
1609
1619
$ describe = self ::$ _attributeBackendTables [$ backendTable ];
1610
- return $ this ->getConnection ()->prepareColumnValue ($ describe ['value ' ], $ value );
1620
+ $ columnName = $ attribute ->isStatic () ? $ attribute ->getAttributeCode () : 'value ' ;
1621
+
1622
+ return $ this ->getConnection ()->prepareColumnValue ($ describe [$ columnName ], $ value );
1611
1623
}
1612
1624
1613
1625
/**
0 commit comments