Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RemoveIndexData.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
15 
17 {
21  private $indexNameBuilder;
22 
26  private $indexStructure;
27 
32  public function __construct(
33  IndexNameBuilder $indexNameBuilder,
34  IndexStructure $indexStructure
35  ) {
36  $this->indexNameBuilder = $indexNameBuilder;
37  $this->indexStructure = $indexStructure;
38  }
39 
44  public function execute(array $stockIds)
45  {
46  foreach ($stockIds as $stockId) {
47  $indexName = $this->indexNameBuilder
48  ->setIndexId(InventoryIndexer::INDEXER_ID)
49  ->addDimension('stock_', (string)$stockId)
50  ->setAlias(Alias::ALIAS_MAIN)
51  ->build();
52  $this->indexStructure->delete($indexName, ResourceConnection::DEFAULT_CONNECTION);
53  }
54  }
55 }
__construct(IndexNameBuilder $indexNameBuilder, IndexStructure $indexStructure)