![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-elasticsearch/Observer/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Elasticsearch\Observer; use Magento\CatalogSearch\Model\Indexer\Fulltext\Processor; use Magento\Elasticsearch\Model\Config; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Catalog\Model\Indexer\Category\Flat\State as FlatState; /** * Checks if a category has changed products and depends on indexer configuration. */ class CategoryProductIndexer implements ObserverInterface { /** * @var Config */ private $config; /** * @var Processor */ private $processor; /** * @var FlatState */ private $flatState; /** * @param Config $config * @param Processor $processor * @param FlatState $flatState */ public function __construct( Config $config, Processor $processor, FlatState $flatState ) { $this->processor = $processor; $this->config = $config; $this->flatState = $flatState; } /** * @inheritdoc */ public function execute(Observer $observer): void { if (!$this->config->isElasticsearchEnabled()) { return; } $productIds = $observer->getEvent()->getProductIds(); if (!empty($productIds) && $this->processor->isIndexerScheduled() && $this->flatState->isFlatEnabled()) { $this->processor->markIndexerAsInvalid(); } } }