Skip to content

Commit 2c13e0c

Browse files
Allow ignored columns for mview to be specified at the subscription level.
1 parent eb50002 commit 2c13e0c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/internal/Magento/Framework/Mview/View/Subscription.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@ class Subscription implements SubscriptionInterface
5757
protected $linkedViews = [];
5858

5959
/**
60-
* List of columns that can be updated in a subscribed table
60+
* List of columns that can be updated in any subscribed table
6161
* without creating a new change log entry
6262
*
6363
* @var array
6464
*/
6565
private $ignoredUpdateColumns = [];
6666

67+
/**
68+
* List of columns that can be updated in a specific subscribed table
69+
* for a specific view without creating a new change log entry
70+
*/
71+
private $ignoredUpdateColumnsBySubscription = [];
72+
6773
/**
6874
* @var Resource
6975
*/
@@ -77,6 +83,7 @@ class Subscription implements SubscriptionInterface
7783
* @param string $tableName
7884
* @param string $columnName
7985
* @param array $ignoredUpdateColumns
86+
* @param array $ignoredUpdateColumnsBySubscription
8087
*/
8188
public function __construct(
8289
ResourceConnection $resource,
@@ -85,7 +92,8 @@ public function __construct(
8592
\Magento\Framework\Mview\ViewInterface $view,
8693
$tableName,
8794
$columnName,
88-
$ignoredUpdateColumns = []
95+
$ignoredUpdateColumns = [],
96+
$ignoredUpdateColumnsBySubscription = []
8997
) {
9098
$this->connection = $resource->getConnection();
9199
$this->triggerFactory = $triggerFactory;
@@ -95,6 +103,7 @@ public function __construct(
95103
$this->columnName = $columnName;
96104
$this->resource = $resource;
97105
$this->ignoredUpdateColumns = $ignoredUpdateColumns;
106+
$this->ignoredUpdateColumnsBySubscription = $ignoredUpdateColumnsBySubscription;
98107
}
99108

100109
/**
@@ -209,7 +218,9 @@ protected function buildStatement($event, $changelog)
209218
$describe = $this->connection->describeTable($tableName)
210219
) {
211220
$columnNames = array_column($describe, 'COLUMN_NAME');
212-
$columnNames = array_diff($columnNames, $this->ignoredUpdateColumns);
221+
$ignoredColumns = array_merge($this->ignoredUpdateColumns,
222+
$this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? []);
223+
$columnNames = array_diff($columnNames, $ignoredColumns);
213224
if ($columnNames) {
214225
$columns = [];
215226
foreach ($columnNames as $columnName) {

0 commit comments

Comments
 (0)