Skip to content

Commit 4364e4c

Browse files
authored
MDEE-463: Commerce Data Extension do not break main process (#283)
1 parent 11b1ed1 commit 4364e4c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

CatalogDataExporter/Plugin/CoverExceptionMview.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
namespace Magento\CatalogDataExporter\Plugin;
1010

11+
use Magento\DataExporter\Model\Indexer\FeedIndexer;
1112
use Magento\Framework\Exception\BulkException;
1213
use Magento\Framework\Mview\Processor;
1314
use Magento\Framework\Mview\View\CollectionFactory;
1415
use Magento\Framework\Mview\ViewInterface;
16+
use Magento\Framework\App\ObjectManager;
1517
use Magento\Framework\Phrase;
1618
use Magento\Framework\Exception\RuntimeException;
1719

@@ -26,7 +28,7 @@ class CoverExceptionMview
2628
* @param CollectionFactory $viewsFactory
2729
*/
2830
public function __construct(
29-
CollectionFactory $viewsFactory,
31+
CollectionFactory $viewsFactory
3032
) {
3133
$this->viewsFactory = $viewsFactory;
3234
}
@@ -40,6 +42,7 @@ public function __construct(
4042
* @return void
4143
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4244
* @throws BulkException
45+
* @throws \Throwable
4346
*/
4447
public function aroundUpdate(Processor $subject, callable $proceed, $group = ''): void
4548
{
@@ -49,9 +52,13 @@ public function aroundUpdate(Processor $subject, callable $proceed, $group = '')
4952
try {
5053
$view->update();
5154
} catch (\Throwable $e) {
52-
$exception->addException(
53-
new RuntimeException(new Phrase('Mview fail %1', [$view->getId()]), $e)
54-
);
55+
if ($this->isDataExporterIndexer($view)) {
56+
$exception->addException(
57+
new RuntimeException(new Phrase('Mview fail %1', [$view->getId()]), $e)
58+
);
59+
} else {
60+
throw $e; // keep original behavior for core indexers
61+
}
5562
}
5663
}
5764

@@ -71,4 +78,9 @@ private function getViewsByGroup(string $group = ''): array
7178
$collection = $this->viewsFactory->create();
7279
return $group ? $collection->getItemsByColumnValue('group', $group) : $collection->getItems();
7380
}
81+
82+
private function isDataExporterIndexer(ViewInterface $view): bool
83+
{
84+
return is_subclass_of(ObjectManager::getInstance()->get($view->getActionClass()), FeedIndexer::class);
85+
}
7486
}

0 commit comments

Comments
 (0)