vuestorefront / magento2-vsbridge-indexer

This is official Vue Storefront, native, Magento2 indexer
https://vuestorefront.io
MIT License
68 stars 90 forks source link

Magento 2.4.4 and php 8.1 #407

Open simonmaass opened 1 year ago

simonmaass commented 1 year ago

Deprecated Functionality: Implicit conversion from float 2.0145020484924316 to int loses precision in /vendor/divante/magento2-vsbridge-indexer/src/module-vsbridge-indexer-core/Console/Command/Rebuild/Rebuild.php on line 143

clinton-origin commented 1 year ago

I only get this error when running "php bin/magento vsbridge:reindex --all". My workaround is to just run each index instead.

php bin/magento indexer:reindex vsbridge_taxrule_indexer && php bin/magento indexer:reindex vsbridge_attribute_indexer && php bin/magento indexer:reindex && vsbridge_product_indexer && php bin/magento indexer:reindex vsbridge_category_indexer && php bin/magento indexer:reindex vsbridge_cms_block_indexer && php bin/magento indexer:reindex vsbridge_cms_page_indexer && php bin/magento indexer:reindex vsbridge_review_indexer

clinton-origin commented 10 months ago

For anyone else visiting this, turns out the above was just the conversion of the time it takes to run each index. I just deleted ". gmdate('H:i:s', $resultTime)" from that line and the index stopped complaining.

simonmaass commented 7 months ago

I am also getting this error:

There is an error in /vendor/symfony/console/Command/Command.php at line: 301
Return value of "Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand\Interceptor::execute()" must be of the type int, "null" returned.#0 /vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /vendor/magento/framework/Interception/Interceptor.php(138): Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand\Interceptor->___callParent('run', Array)
#2 /vendor/magento/framework/Interception/Interceptor.php(153): Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /generated/code/Divante/VsbridgeIndexerCore/Console/Command/RebuildEsIndexCommand/Interceptor.php(77): Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand\Interceptor->___callPlugins('run', Array, Array)
#4 /vendor/symfony/console/Application.php(1040): Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand\Interceptor), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /bin/magento(23): Symfony\Component\Console\Application->run()
#9 {main}
simonmaass commented 7 months ago

@bloodf as you made the last commit... is this still maintained?

clinton-origin commented 7 months ago

@simonmaass This is not maintained from what I can see, we are on our own with this.

To answer your question above, just add a return 0; to the end of the RebuildEsIndexCommand.php

I am no php developer but I guess under the new php 8 rules the excute fucntion needs to return a value so setting return 0; makes the error go away.

`protected function execute(InputInterface $input, OutputInterface $output) { $output->setDecorated(true);

    try {
        $this->appState->getAreaCode();
    } catch (LocalizedException $exception) {
        $this->appState->setAreaCode(FrontNameResolver::AREA_CODE);
    }

    $store = $input->getOption(self::INPUT_STORE);
    $allStores = $input->getOption(self::INPUT_ALL_STORES);

    if (!$store && !$allStores) {
        $output->writeln(
            "<comment>Not enough information provided, nothing has been reindexed. Try using --help for more information.</comment>"
        );

        return;
    }

    $this->eventManager->dispatch(
        'vsbridge_indexer_reindex_before',
        [
            'store' => $store,
            'allStores' => $allStores,
        ]
    );

    $rebuildIndicesCommand = $this->rebuildIndicesFactory->create($output);
    $rebuildIndicesCommand->execute($input->getOption(self::INPUT_STORE));

    $this->eventManager->dispatch(
        'vsbridge_indexer_reindex_after',
        [
            'store' => $store,
            'allStores' => $allStores,
        ]
    );
        return 0;    
}`
simonmaass commented 4 months ago

Created a patch file...

--- /dev/null
+++ ../src/module-vsbridge-indexer-core/Console/Command/RebuildEsIndexCommand.php
@@ -96,7 +96,7 @@
 Try using --help for more information.</comment>"
             );

-            return;
+            return \Magento\Framework\Console\Cli::RETURN_FAILURE;
         }

         $this->eventManager->dispatch(
@@ -109,6 +109,8 @@

         $rebuildIndicesCommand = $this->rebuildIndicesFactory->create($output);
         $rebuildIndicesCommand->execute($input->getOption(self::INPUT_STORE));
+
+        return \Magento\Framework\Console\Cli::RETURN_SUCCESS;

         $this->eventManager->dispatch(
             'vsbridge_indexer_reindex_after',