vuestorefront / magento2-vsbridge-indexer

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

Error While creating a Custom vsbridge Indexer #396

Open tajveez-73 opened 3 years ago

tajveez-73 commented 3 years ago

Hello,

I am using

Magento: 2.4.2 magento2-vsbridge-indexer: 2.0.1 VSF: 1.2.1 Elasticsearch: 7.6.1

I am trying to create a custom Indexer by Following Module Divante\VsbridgeIndexerReview After following all the code when I try to reindex I get the following error

TM Custom Indexer for VSF index PHP Fatal error:  Uncaught Error: Class 'TM\CustomIndexer\Model\Indexer\CustomIndex' not found in /microcloud/domains/devma2/domains/devadmin2.bedfactorydirect.co.uk/http/generated/code/TM/CustomIndexer/Model/Indexer/CustomIndex/Interceptor.php:7
Stack trace:
#0 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/composer/ClassLoader.php(444): include()
#1 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/microcloud/dom...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('TM\\CustomIn...')
#3 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): spl_autoload_call('TM\\CustomIn...')
#4 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactor in /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/generated/code/TM/CustomIndexer/Model/Indexer/CustomIndex/Interceptor.php on line 7

Fatal error: Uncaught Error: Class 'TM\CustomIndexer\Model\Indexer\CustomIndex' not found in /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/generated/code/TM/CustomIndexer/Model/Indexer/CustomIndex/Interceptor.php:7
Stack trace:
#0 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/composer/ClassLoader.php(444): include()
#1 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/microcloud/dom...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('TM\\CustomIn...')
#3 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): spl_autoload_call('TM\\CustomIn...')
#4 /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactor in /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/generated/code/TM/CustomIndexer/Model/Indexer/CustomIndex/Interceptor.php on line 7

When I checked the code the class TM\CustomIndexer\Model\Indexer\CustomIndex wasn't created so I checked the reference module this class also didn't exist Divante\VsbridgeIndexerReview\Model\Indexer\Review which was being used in di.xml

    <virtualType name="Divante\VsbridgeIndexerReview\Model\Indexer\Review"
                 type="Divante\VsbridgeIndexerCore\Indexer\Base">
        <arguments>
            <argument name="typeName" xsi:type="string">review</argument>
        </arguments>
    </virtualType>

So I created my own class using this URL

but then I am getting another error.

TM Custom Indexer for VSF index exception: Type Error occurred when creating object: TM\CustomIndexer\Model\Indexer\CustomIndex\Interceptor, Argument 1 passed to TM\CustomIndexer\Model\Indexer\CustomIndex\Interceptor::__construct() must be an instance of Divante\VsbridgeIndexerCore\Indexer\GenericIndexerHandler, instance of Divante\VsbridgeIndexerCore\Indexer\Action\ActionFactory given, called in /microcloud/domains/devma2/domains/devadmin2.tm.co.uk/http/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121

It's quite weird because I am already adding the type of Divante\VsbridgeIndexerCore\Indexer\GenericIndexerHandler in class TM\CustomIndexer\Model\Indexer\CustomIndex What is the correct way to create a custom indexer and if it is the correct way to create an indexer how to get rid of these errors. Also, if we needed to create this class, why isn't this in the vendor module?

Thanks.