88
99namespace Magento \CatalogDataExporter \Plugin ;
1010
11+ use Magento \DataExporter \Model \Indexer \FeedIndexer ;
1112use Magento \Framework \Exception \BulkException ;
1213use Magento \Framework \Mview \Processor ;
1314use Magento \Framework \Mview \View \CollectionFactory ;
1415use Magento \Framework \Mview \ViewInterface ;
16+ use Magento \Framework \App \ObjectManager ;
1517use Magento \Framework \Phrase ;
1618use 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