Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions
SetInitialSearchWeightForAttributes Class Reference
Inheritance diagram for SetInitialSearchWeightForAttributes:
DataPatchInterface PatchVersionInterface PatchInterface DependentPatchInterface

Public Member Functions

 __construct (IndexerInterfaceFactory $indexerFactory, ProductAttributeRepositoryInterface $attributeRepository, State $state)
 
 apply ()
 
 getAliases ()
 

Static Public Member Functions

static getDependencies ()
 
static getVersion ()
 

Detailed Description

Deprecated:
See also
\Magento\ElasticSearch

Definition at line 19 of file SetInitialSearchWeightForAttributes.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( IndexerInterfaceFactory  $indexerFactory,
ProductAttributeRepositoryInterface  $attributeRepository,
State  $state 
)

SetInitialSearchWeightForAttributes constructor.

Parameters
IndexerInterfaceFactory$indexerFactory
ProductAttributeRepositoryInterface$attributeRepository
State$state

Definition at line 42 of file SetInitialSearchWeightForAttributes.php.

46  {
47  $this->indexerFactory = $indexerFactory;
48  $this->attributeRepository = $attributeRepository;
49  $this->state = $state;
50  }

Member Function Documentation

◆ apply()

apply ( )

{Run code inside patch If code fails, patch must be reverted, in case when we are speaking about schema - than under revert means run PatchInterface::revert()If we speak about data, under revert means: $transaction->rollback()

Returns
$this
}

Implements PatchInterface.

Definition at line 55 of file SetInitialSearchWeightForAttributes.php.

56  {
57  $this->setWeight('sku', 6);
58  $this->setWeight('name', 5);
59  $indexer = $this->indexerFactory->create()->load('catalogsearch_fulltext');
60  $this->state->emulateAreaCode(
61  \Magento\Framework\App\Area::AREA_CRONTAB,
62  function () use ($indexer) {
63  $indexer->reindexAll();
64  }
65  );
66  }

◆ getAliases()

getAliases ( )

{Get aliases (previous names) for the patch.

Returns
string[]
}

Implements PatchInterface.

Definition at line 87 of file SetInitialSearchWeightForAttributes.php.

88  {
89  return [];
90  }

◆ getDependencies()

static getDependencies ( )
static

{Get array of patches that have to be executed prior to this.example of implementation:[ \Vendor_Name\Module_Name\Setup\Patch\Patch1::class, \Vendor_Name\Module_Name\Setup\Patch\Patch2::class ]

Returns
string[]
}

Implements DependentPatchInterface.

Definition at line 71 of file SetInitialSearchWeightForAttributes.php.

72  {
73  return [];
74  }

◆ getVersion()

static getVersion ( )
static

{This version associate patch with Magento setup version. For example, if Magento current setup version is 2.0.3 and patch version is 2.0.2 than this patch will be added to registry, but will not be applied, because it is already applied by old mechanism of UpgradeData.php script

Returns
string
Deprecated:
since appearance, required for backward compatibility
}

Implements PatchVersionInterface.

Definition at line 79 of file SetInitialSearchWeightForAttributes.php.

80  {
81  return '2.0.0';
82  }

The documentation for this class was generated from the following file: