11
11
use Magento \Framework \Mview \View \StateInterface ;
12
12
13
13
/**
14
- * Class Subscription
15
- *
16
- * @package Magento\Framework\Mview\View
14
+ * Class Subscription for handling partial indexation triggers
17
15
*/
18
16
class Subscription implements SubscriptionInterface
19
17
{
@@ -57,13 +55,19 @@ class Subscription implements SubscriptionInterface
57
55
protected $ linkedViews = [];
58
56
59
57
/**
60
- * List of columns that can be updated in a subscribed table
58
+ * List of columns that can be updated in any subscribed table
61
59
* without creating a new change log entry
62
60
*
63
61
* @var array
64
62
*/
65
63
private $ ignoredUpdateColumns = [];
66
64
65
+ /**
66
+ * List of columns that can be updated in a specific subscribed table
67
+ * for a specific view without creating a new change log entry
68
+ */
69
+ private $ ignoredUpdateColumnsBySubscription = [];
70
+
67
71
/**
68
72
* @var Resource
69
73
*/
@@ -77,6 +81,7 @@ class Subscription implements SubscriptionInterface
77
81
* @param string $tableName
78
82
* @param string $columnName
79
83
* @param array $ignoredUpdateColumns
84
+ * @param array $ignoredUpdateColumnsBySubscription
80
85
*/
81
86
public function __construct (
82
87
ResourceConnection $ resource ,
@@ -85,7 +90,8 @@ public function __construct(
85
90
\Magento \Framework \Mview \ViewInterface $ view ,
86
91
$ tableName ,
87
92
$ columnName ,
88
- $ ignoredUpdateColumns = []
93
+ $ ignoredUpdateColumns = [],
94
+ $ ignoredUpdateColumnsBySubscription = []
89
95
) {
90
96
$ this ->connection = $ resource ->getConnection ();
91
97
$ this ->triggerFactory = $ triggerFactory ;
@@ -95,6 +101,7 @@ public function __construct(
95
101
$ this ->columnName = $ columnName ;
96
102
$ this ->resource = $ resource ;
97
103
$ this ->ignoredUpdateColumns = $ ignoredUpdateColumns ;
104
+ $ this ->ignoredUpdateColumnsBySubscription = $ ignoredUpdateColumnsBySubscription ;
98
105
}
99
106
100
107
/**
@@ -209,7 +216,14 @@ protected function buildStatement($event, $changelog)
209
216
$ describe = $ this ->connection ->describeTable ($ tableName )
210
217
) {
211
218
$ columnNames = array_column ($ describe , 'COLUMN_NAME ' );
212
- $ columnNames = array_diff ($ columnNames , $ this ->ignoredUpdateColumns );
219
+ $ ignoredColumnsBySubscription = array_filter (
220
+ $ this ->ignoredUpdateColumnsBySubscription [$ changelog ->getViewId ()][$ this ->getTableName ()] ?? []
221
+ );
222
+ $ ignoredColumns = array_merge (
223
+ $ this ->ignoredUpdateColumns ,
224
+ array_keys ($ ignoredColumnsBySubscription )
225
+ );
226
+ $ columnNames = array_diff ($ columnNames , $ ignoredColumns );
213
227
if ($ columnNames ) {
214
228
$ columns = [];
215
229
foreach ($ columnNames as $ columnName ) {
0 commit comments