8
8
use Magento \Framework \Model \ResourceModel \Db \AbstractDb ;
9
9
use Magento \Framework \Model \ResourceModel \Db \Context ;
10
10
use Magento \Framework \Serialize \SerializerInterface ;
11
+ use Magento \Framework \App \ResourceConnection ;
11
12
12
13
class Node extends AbstractDb
13
14
{
14
15
protected $ serializer ;
16
+ protected $ resource ;
15
17
16
18
public function __construct (
17
19
Context $ context ,
18
20
SerializerInterface $ serializer ,
21
+ ResourceConnection $ resource ,
19
22
$ connectionName = null
20
23
) {
21
24
$ this ->serializer = $ serializer ;
25
+ $ this ->resource = $ resource ;
22
26
parent ::__construct ($ context , $ connectionName );
23
27
}
24
28
@@ -29,8 +33,9 @@ protected function _construct()
29
33
30
34
protected function _afterSave (AbstractModel $ object )
31
35
{
32
- $ connection = $ this ->getConnection ();
33
- $ connection ->delete ('snowmenu_customer ' , ['node_id = ? ' => $ object ->getNodeId ()]);
36
+ $ connection = $ this ->resource ->getConnection ();
37
+ $ tableName = $ this ->resource ->getTableName ('snowmenu_customer ' );
38
+ $ connection ->delete ($ tableName , ['node_id = ? ' => $ object ->getNodeId ()]);
34
39
35
40
$ nodeCustomerGroups = $ object ->getData ('customer_groups ' );
36
41
if ($ nodeCustomerGroups && is_string ($ nodeCustomerGroups )) {
@@ -44,7 +49,7 @@ protected function _afterSave(AbstractModel $object)
44
49
];
45
50
}
46
51
if ($ nodeCustomerGroups ) {
47
- $ connection ->insertMultiple (' snowmenu_customer ' , $ insertData );
52
+ $ connection ->insertMultiple ($ tableName , $ insertData );
48
53
}
49
54
50
55
return parent ::_afterSave ($ object );
0 commit comments