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, I got the following error: *Spryker\Shared\ZedRequest\Client\Exception\TransferNotFoundExceptio

ULL0N440J
ULL0N440J Posts: 184 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi, I got the following error:

Spryker\Shared\ZedRequest\Client\Exception\TransferNotFoundException - No class name given for Transfer generation.

I actually know what this error is about (returning a proper transfer). In my usecase I am returning an array of MerchantRelationshipTransfer. Do I need to create a
MerchantRelationshipCollectionTransfer() (CollectionTransfer doesn't exist yet) or is it possible to solve it "easier"?

Comments

  • UM53ZHLTF
    UM53ZHLTF Posts: 43 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited February 2020

    Probably just remove the *Transfer suffix from your property. The declaration should be without just the ClassName

  • ULL0N440J
    ULL0N440J Posts: 184 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited February 2020

    Not sure if I got you right. This here is my current code

    /**
     * @param  \Generated\Shared\Transfer\CompanyBusinessUnitTransfer $companyBusinessUnit
     * @return \Generated\Shared\Transfer\MerchantRelationshipTransfer[]
     */
    public function getMerchantRelationshipCollectionByOwnerCompanyBusinessUnitAction(CompanyBusinessUnitTransfer $companyBusinessUnit) {
        $facade = new MerchantRelationshipFacade();
        $allMR = $facade->getMerchantRelationshipCollection();
        $currentMR = [];
    
        foreach($allMR as $merchantRelation) {
            if($merchantRelation->getOwnerCompanyBusinessUnit()->getIdCompanyBusinessUnit() == $companyBusinessUnit->getIdCompanyBusinessUnit()) {
                $currentMR[] = $merchantRelation;
            }
        }
    
        return $currentMR;
    }
    
  • UM53ZHLTF
    UM53ZHLTF Posts: 43 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited February 2020

    Ok you can return an array of Transfers. Thats not a problem. It looks more like you dont have the MerchantRelationshipTransfer in first place. Does it exist?

  • UM53ZHLTF
    UM53ZHLTF Posts: 43 πŸ§‘πŸ»β€πŸš€ - Cadet

    Side note, don't instantiate business objects in your code, pass them as dependencies. So the MerchantRelationshipFacadeshould be a dependency

  • ULL0N440J
    ULL0N440J Posts: 184 πŸ§‘πŸ»β€πŸš€ - Cadet

    It looks more like you dont have the MerchantRelationshipTransfer in first place. Does it exist?Β (edited)

    the $allMR contains several Objects of type MerchantRelationshipTransfer

  • UM53ZHLTF
    UM53ZHLTF Posts: 43 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ah let me guess, you trying it from a gatewayController right?

  • UM53ZHLTF
    UM53ZHLTF Posts: 43 πŸ§‘πŸ»β€πŸš€ - Cadet

    so for a client/Stub call. Then you need a proper wrapper transfer yes.

  • ULL0N440J
    ULL0N440J Posts: 184 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ah, alright πŸ˜… there we go, sorry if I wasn't clear enough at the beginning.

  • ULL0N440J
    ULL0N440J Posts: 184 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited February 2020

    Side note, don't instantiate business objects in your code, pass them as dependencies. So the MerchantRelationshipFacadeshould be a dependency

    Thanks for the hint, this was just a first try. I'll move this code anyway. Currently this is nested in the GatewayController from product-list. I'll move this specific function to merchant-relation. There I can access the facade directly.

  • UM53ZHLTF
    UM53ZHLTF Posts: 43 πŸ§‘πŸ»β€πŸš€ - Cadet

    no worries, the easiest is to just wrap this in *ResponseTransfer where you also set the status

  • UM53ZHLTF
    UM53ZHLTF Posts: 43 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok πŸ‘

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited February 2020

    Side note, don’t instantiate business objects in your code, pass them as dependencies. So the MerchantRelationshipFacadeshould be a dependency

    so in case of a GatewayController it must not be a dependency, it should be resolved by $this->getFacade() to the right (current module’s) facade πŸ˜‰

  • ULL0N440J
    ULL0N440J Posts: 184 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited February 2020

    Moved everything nice and clean into merchant-relation bundle today.
    Getting back to this topic: how do I wrap an entity into a responseTransfer?
    My first thought on this would be to define a new transferObject like project/src/Pyz/Shared/MerchantRelation/Transfer/merchant_relationship_collection.transfer.xml πŸ˜