What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi, Can anyone please suggest what might be the reason to receive below error.

U01AZE27XGV
U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi, Can anyone please suggest what might be the reason to receive below error.

Comments

  • could you show us the code around the reported line of failure?

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited January 2021

    which PHP version are you using?
    And can you share the code snipped form this error instead of the screenshot?

  • Ahmed Sabaa
    Ahmed Sabaa Senior Application Architect @Spryker Sprykee Posts: 54 πŸ§‘πŸ»β€πŸš€ - Cadet

    Why did you create a Pyz business class that is called β€œTransfer”? Transfer objects do not have an extension mechanism, you factory is extending a Sprkyer factory that has a PHP typehint there. Those interfaces between your extended factory and the base Spryker factory do not match

  • Ahmed Sabaa
    Ahmed Sabaa Senior Application Architect @Spryker Sprykee Posts: 54 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited January 2021

    You can just use the Generated\DataImportConfigurationTransfer in your function and it will all be fine

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet
    /**
     * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface
     */
    protected function createDealerPortalCustomerImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer)
    {
        $dataImporter = $this->getCsvDataImporterFromConfig(
            $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer)
        );
    
        $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker();
        $dataSetStepBroker
            ->addStep(new DealerPortalCustomerWriterStep());
    
        $dataImporter->addDataSetStepBroker($dataSetStepBroker);
    
        return $dataImporter;
    }
    
    /**
     * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer
     *
     * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|null
     */
    public function getDataImporterByType(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): ?DataImporterInterface
    {
        switch ($dataImportConfigurationActionTransfer->getDataEntity()) {
            case DataImportConfig::IMPORT_TYPE_DPC;
                return $this->createDealerPortalCustomerImporter($dataImportConfigurationActionTransfer);
            default:
                return null;
        }
    }
    
  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    You didn't import/use the transfer class

  • Ahmed Sabaa
    Ahmed Sabaa Senior Application Architect @Spryker Sprykee Posts: 54 πŸ§‘πŸ»β€πŸš€ - Cadet

    It’s a PHP exception that is not relevant to the code really, it’s as I said, the function signature problem

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    The transfer class is not on the use block, that's why php is assuming it is on the same namespace as the factory

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    have added use Generated\Shared\Transfer\DataImportConfigurationActionTransfer; to DataImportBusinessFactory.php

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    still same error

  • technically it should not be possible that the error is the same after the import was added

  • let’s dive into this.

  • can you show us where createDealerPortalCustomerImporter() is called?

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

    can you also copy paste the error as plain text here?

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    createDealerPortalCustomerImporter() is called on the top in DataImportBusinessFactory class

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    Here is the error: Fatal error: Declaration of Pyz\Zed\DataImport\Business\DataImportBusinessFactory::getDataImporterByType(Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): ?Pyz\Zed\DataImport\Business\DataImporterInterface must be compatible with Spryker\Zed\DataImport\Business\DataImportBusinessFactory::getDataImporterByType(Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): ?Spryker\Zed\DataImport\Business\Model\DataImporterInterface in /data/src/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.php on line 82
    ErrorException - Exception: FATAL ERROR - Declaration of Pyz\Zed\DataImport\Business\DataImportBusinessFactory::getDataImporterByType(Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): ?Pyz\Zed\DataImport\Business\DataImporterInterface must be compatible with Spryker\Zed\DataImport\Business\DataImportBusinessFactory::getDataImporterByType(Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): ?Spryker\Zed\DataImport\Business\Model\DataImporterInterface
    in /data/src/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.php (82)

    Command: /data/vendor/bin/console data:import:dealer-portal-customer

    Trace:

    0 /data/vendor/spryker/error-handler/src/Spryker/Shared/ErrorHandler/ErrorHandlerEnvironment.php(99): Spryker\Shared\ErrorHandler\ErrorHandler->handleFatal()

    1 [internal function]: Spryker\Shared\ErrorHandler\ErrorHandlerEnvironment->Spryker\Shared\ErrorHandler{closure}()

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

    are you using PHP 7.2 or 7.4?

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    7.4

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    it seems you are also missing the import of the Spryker\Zed\DataImport\Business\Model\DataImporterInterface

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    I imported this too

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    Now showing data importer not found

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

    is your Pyz\Zed\DataImport\Business\DataImporterInterface extending Spryker\Zed\DataImport\Business\Model\DataImporterInterface?

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    Have imported Spryker\Zed\DataImport\Business\Model\DataImporterInterface in DataImportBusinessFactory

  • U01AZE27XGV
    U01AZE27XGV Posts: 111 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UJN2JRU4F any inputs?

  • πŸ‘‰ DM