Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createScripts example
// reset last id to start iterator at the beginning
$offset
->
setLastId
(
null
)
;
return
$this
->
createIndexingMessage
(
$offset
,
$context
)
;
}
private
function
init
(
)
: IndexerOffset
{
$this
->connection->
executeStatement
(
'DELETE FROM elasticsearch_index_task'
)
;
$this
->
createScripts
(
)
;
$languages
=
$this
->languageProvider->
getLanguages
(
Context::
createDefaultContext
(
)
)
;
$timestamp
=
new
\
DateTime
(
)
;
foreach
(
$languages
as
$language
)
{
$this
->
createLanguageIndex
(
$language
,
$timestamp
)
;
}
return
new
IndexerOffset
(
array_values
(
$languages
->
getIds
(
)
)
,
$index
=
$alias
. '_' .
$offset
->
getTimestamp
(
)
;
// return indexing message for current offset
return
new
ElasticsearchIndexingMessage
(
new
IndexingDto
(
array_values
(
$ids
)
,
$index
,
$entity
)
,
$offset
, Context::
createDefaultContext
(
)
)
;
}
private
function
init
(
)
: IndexerOffset
{
$this
->connection->
executeStatement
(
'DELETE FROM elasticsearch_index_task'
)
;
$this
->
createScripts
(
)
;
$timestamp
=
new
\
DateTime
(
)
;
$this
->
createIndex
(
$timestamp
)
;
return
new
IndexerOffset
(
[
]
,
$this
->registry->
getDefinitionNames
(
)
,
$timestamp
->
getTimestamp
(
)
)
;
}