Skip to content

Commit d24c28f

Browse files
committed
ACP2E-1458: Product is not visible on the Storefront after a staging update enabling it is applied
1 parent c9d1397 commit d24c28f

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
<preference for="Magento\Framework\HTTP\ClientInterface" type="Magento\Framework\HTTP\Client\Curl" />
213213
<preference for="Magento\Framework\Interception\ConfigLoaderInterface" type="Magento\Framework\Interception\PluginListGenerator" />
214214
<preference for="Magento\Framework\Interception\ConfigWriterInterface" type="Magento\Framework\Interception\PluginListGenerator" />
215+
<preference for="Magento\Framework\Mview\View\SubscriptionStatementPostprocessorInterface" type="Magento\Framework\Mview\View\CompositeSubscriptionStatementPostprocessor" />
215216
<type name="Magento\Framework\Model\ResourceModel\Db\TransactionManager" shared="false" />
216217
<type name="Magento\Framework\Acl\Data\Cache">
217218
<arguments>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Mview\View;
9+
10+
class CompositeSubscriptionStatementPostprocessor implements SubscriptionStatementPostprocessorInterface
11+
{
12+
/**
13+
* @var SubscriptionStatementPostprocessorInterface[]
14+
*/
15+
private $postprocessors;
16+
17+
/**
18+
* @param SubscriptionStatementPostprocessorInterface[] $postprocessors
19+
*/
20+
public function __construct(array $postprocessors = [])
21+
{
22+
$this->postprocessors = $postprocessors;
23+
}
24+
25+
/**
26+
* @inheritdoc
27+
*/
28+
public function process(string $tableName, string $event, string $statement): string
29+
{
30+
foreach ($this->postprocessors as $postprocessor) {
31+
$statement = $postprocessor->process($tableName, $event, $statement);
32+
}
33+
34+
return $statement;
35+
}
36+
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class Subscription implements SubscriptionInterface, SubscriptionTriggersInterfa
8787
*/
8888
private $mviewConfig;
8989

90+
/**
91+
* @var SubscriptionStatementPostprocessorInterface
92+
*/
93+
private $statementPostprocessor;
94+
9095
/**
9196
* @var Trigger[]
9297
*/
@@ -102,6 +107,7 @@ class Subscription implements SubscriptionInterface, SubscriptionTriggersInterfa
102107
* @param array $ignoredUpdateColumns
103108
* @param array $ignoredUpdateColumnsBySubscription
104109
* @param Config|null $mviewConfig
110+
* @param SubscriptionStatementPostprocessorInterface|null $statementPostprocessor
105111
*/
106112
public function __construct(
107113
ResourceConnection $resource,
@@ -112,7 +118,8 @@ public function __construct(
112118
$columnName,
113119
$ignoredUpdateColumns = [],
114120
$ignoredUpdateColumnsBySubscription = [],
115-
Config $mviewConfig = null
121+
?Config $mviewConfig = null,
122+
?SubscriptionStatementPostprocessorInterface $statementPostprocessor = null
116123
) {
117124
$this->connection = $resource->getConnection();
118125
$this->triggerFactory = $triggerFactory;
@@ -124,6 +131,8 @@ public function __construct(
124131
$this->ignoredUpdateColumns = $ignoredUpdateColumns;
125132
$this->ignoredUpdateColumnsBySubscription = $ignoredUpdateColumnsBySubscription;
126133
$this->mviewConfig = $mviewConfig ?? ObjectManager::getInstance()->get(Config::class);
134+
$this->statementPostprocessor = $statementPostprocessor
135+
?? ObjectManager::getInstance()->get(SubscriptionStatementPostprocessorInterface::class);
127136
}
128137

129138
/**
@@ -324,13 +333,16 @@ protected function buildStatement(string $event, ViewInterface $view): string
324333
}
325334
$columns = $this->prepareColumns($view, $event);
326335

327-
return sprintf(
336+
$statement = sprintf(
328337
$trigger,
329338
$this->getProcessor()->getPreStatements(),
330339
$this->connection->quoteIdentifier($this->resource->getTableName($changelog->getName())),
331340
implode(', ', $columns['column_names']),
332341
implode(', ', $columns['column_values'])
333342
);
343+
$statement = $this->statementPostprocessor->process($this->getTableName(), $event, $statement);
344+
345+
return $statement;
334346
}
335347

336348
/**
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Mview\View;
9+
10+
interface SubscriptionStatementPostprocessorInterface
11+
{
12+
/**
13+
* Postprocess subscription statement.
14+
*
15+
* @param string $tableName
16+
* @param string $event
17+
* @param string $statement
18+
* @return string
19+
*/
20+
public function process(string $tableName, string $event, string $statement): string;
21+
}

0 commit comments

Comments
 (0)