@@ -135,7 +135,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
135135 ? (new \DateTime ($ input ->getOption (self ::OPTION_TO )))->format (\DateTimeInterface::W3C )
136136 : null ;
137137
138- return $ this ->prepareForExport ($ batchSize , $ output , $ from , $ to , $ state );
138+ $ output ->writeln (
139+ sprintf (
140+ '<info>Start updating UUID with parameters [state=%s, from=%s, to=%s, batch_size=%s]</info> ' ,
141+ $ state ?: 'all ' ,
142+ $ from ?: date (\DateTimeInterface::W3C , 0 ),
143+ $ to ?: date (\DateTimeInterface::W3C ),
144+ $ batchSize
145+ )
146+ );
147+
148+ $ updatedEntities = $ this ->assignUuidsToOrderEntities ($ batchSize , $ from , $ to , $ state );
149+
150+ $ output ->writeln ("<info>Assign UUID completed successfully, $ updatedEntities entities updated</info> " );
151+
152+ return CLI ::RETURN_SUCCESS ;
139153 } catch (\Throwable $ e ) {
140154 $ output ->writeln ('<error>Failed to update UUID. Check logs</error> ' );
141155 $ this ->logger ->error (
@@ -150,51 +164,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
150164 * Updating UUID
151165 *
152166 * @param int $batchSize
153- * @param OutputInterface $output
154- * @param string $from
155- * @param string $to
167+ * @param string|null $from
168+ * @param string|null $to
156169 * @param string $state
157170 * @return int
158171 */
159- public function prepareForExport (
172+ public function assignUuidsToOrderEntities (
160173 int $ batchSize ,
161- OutputInterface $ output ,
162174 string $ from = null ,
163175 string $ to = null ,
164176 string $ state = ''
165- ) {
166- try {
167- $ output ->writeln (
168- sprintf (
169- '<info>Start updating UUID with parameters [state=%s, from=%s, to=%s, batch_size=%s]</info> ' ,
170- $ state ?: 'all ' ,
171- $ from ?: date (\DateTimeInterface::W3C , 0 ),
172- $ to ?: date (\DateTimeInterface::W3C ),
173- $ batchSize
174- )
175- );
176-
177- $ updatedEntities = 0 ;
178- foreach ($ this ->getOrders ($ state , $ batchSize , $ from , $ to ) as $ type => $ entityIds ) {
179- $ this ->uuidManager ->assignBulk ($ entityIds , $ type );
180- $ updatedEntities += count ($ entityIds );
181- }
182- $ output ->writeln (
183- sprintf (
184- '<info>Update completed successfully, %s entities updated</info> ' ,
185- $ updatedEntities
186- )
187- );
188- return Cli::RETURN_SUCCESS ;
189-
190- } catch (\Throwable $ e ) {
191- $ output ->writeln ('<error>Failed to update UUID. Check logs</error> ' );
192- $ this ->logger ->error (
193- sprintf ('Command "%s" failed. Error message: %s ' , self ::COMMAND_NAME , $ e ->getMessage ())
194- );
195-
196- return Cli::RETURN_FAILURE ;
177+ ): int {
178+ $ updatedEntities = 0 ;
179+ foreach ($ this ->getOrders ($ state , $ batchSize , $ from , $ to ) as $ type => $ entityIds ) {
180+ $ this ->uuidManager ->assignBulk ($ entityIds , $ type );
181+ $ updatedEntities += count ($ entityIds );
197182 }
183+ return $ updatedEntities ;
198184 }
199185
200186 /**
0 commit comments