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 am currently manipulating the prices in our shop with a company-based margin. So far - so good

ULL0N440J
ULL0N440J Posts: 184 πŸ§‘πŸ»β€πŸš€ - Cadet
edited September 2019 in Help

Hi, I am currently manipulating the prices in our shop with a company-based margin. So far - so good. But now I am stuck at one last point: the PriceProductMapper seems to has no link to the customer at all.

I was wondering, if I could prepare accessing the current customer (->getCompanyUserTransfer()->getCompanyBusinessUnit()->getMargin()) in the DependencyProvider. I've added the following function in the DependencyProvider order to access the customer of QuoteTransfer:

protected function addQuoteClient(Container $container)
    {
        $container[static::CLIENT_QUOTE] = function (Container $container) {
            return new PriceProductToQuoteClientBridge($container->getLocator()->quote()->client());
        };

        return $container;
    }

calling quote() there brings up the message Method 'quote' not found in \Generated\Zed\Ide\AutoCompletion|\Spryker\Shared\Kernel\LocatorLocatorInterface. Any ideas, how to get this running? 😨

Β«1

Comments

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

    More Meta: when returning the MoneyValueTransfer, i am adding an individual multiplier in /src/Pyz/Zed/PriceProduct/Business/Model/Product/PriceProductMapper.php.
    This file doesn't know the Customer (yet). See my thoughts on how to solve this above)

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    in which method are you using calling the addQuoteClient method? Is is provideBusinessLayerDependencies()?

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    another point: if possible, try to get rid of bridges in project scope, e.g. instead of return new PriceProductToQuoteClientBridge() just return return $container->getLocator()->quote()->client()

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    it’s a general Spryker recommendation

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

    in which method are you using calling the addQuoteClientmethod? Is is provideBusinessLayerDependencies()?

    Yes. /src/Pyz/Zed/PriceProduct/PriceProductDependencyProvider.php:provideBusinessLayerDependencies()

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    Now, to the point: you might be doing something wrong, if you intent to provide Client in Zed …

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    First of all, you might end-up in β€œZed is calling Zed” situation, which for sure you don’t want to do.

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    On the other side, Client might try to query Session, which is not right to do from Zed

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    Can you investigate, what’s your target method in the client, what should it call eventually?

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    if you feel like providing PriceProductMapper with information about customer - I would go for extending the incoming transfer object with customerId and passing it from Yves. But it is still doesn’t feel right, there might be some β€œhook” point where you would introduce your plugin or so. I just don’t know your exact business use case

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

    My scenario is: I want to receive the current customer. I thought it was refrenced and accessible in the provided QuoteTransfer πŸ€” I had a look at another function CompanyUserInvitationPageDependencyProvider:addCustomerclient() where the CustomerClient was called from given container,.

    In an Yves module I am accessing the current customer with CustomerClient return $customer->getCompanyUserTransfer()->getCompanyBusinessUnit()->getMargeRate();

    I get you, doesn't appear to be correct to open a Client to request data from Zed πŸ€¦β€β™‚οΈ

    Now, to the point: you might be doing something wrong, if you intent to provide Client in Zed …

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    If it’s not exactly what you’re looking for, maybe you could have a look how it is implemented and find the good solution?

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    I get you, doesn’t appear to be correct to open a Client to request data from Zed πŸ€¦β€β™‚οΈ

    Zed is customer-session agnostic, period. You can pass customer ID from Yves to Zed, and then Zed can fetch customer information, if needed.

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    I thought it was refrenced and accessible in the provided QuoteTransfer

    that should be it, quote must have a customerId (if it’s not a guest)

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

    We've already had a look at product lists. We couldn't use this, because we would have to import our products as lists many times (each time, when someone wants to add a new margin. This could reach from 0.1% to x%.. think this would not be viable)

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    @ULL0N440J product lists won’t work here. What about the link I’ve sent above - prices per Merchant relation?

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    I would not go towards persisting the all (prices * customers) combinations. Rather store customer margin for customer, and then add % on the fly, when you calculate the quote, by introducing a new item for your calculation stack. That worked for us just perfectly fine.

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    just don’t forget to store the current margin value together with the sales order, to make sure you can β€œexplain” the price in the future

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    but really, have a look at β€œprices per Merchant relation” feature

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

    prices per Merchant relation

    I get you. We've had a look on this way already, too. Quite difficult to explain our whole Idea for the Shop:

    We would have to set the merchant relations in Yves. Our (kind-of)Admins won't be able to access Zed.
    This is where I failed last time; I wasn't able to create merchant-relations from yves 😣

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    ahhh, you’re building market place. So you want the Yves to be also a place where vendors define prices for the customers..

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited September 2019

    hmmm, yeah, it very depends on your specific and the way how you’re building things already.. Why is it not possible to create a new β€œrelation” by doing Yves->Zed call?

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

    Why is it not possible to create a new β€œrelation” by doing Yves->Zed call?

    Didn't find out, how to solve this properly. There was no Client I could use. All I found (but didn't help to get further) was a MerchantRelationToCSV... πŸ€”

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    Well, then you need to introduce one, definitely

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    along with gateway controller(action) and maybe a dedicated facade method. That would sound to me as a right solution

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

    I will definitly get back to this later. We've committed to solve it quick and dirty for now. I've translated every call to setNetAmount() by given multiplier. As long as a customer is provided this works fine for us.

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

    Going back to the initial question - How can I access the customer(client) from the container? The container appears to have a quoteTransfer linked to it. This contains a customerTransfer / customerID

  • Andriy Netseplyayev
    Andriy Netseplyayev Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    Now I lost you..
    now you want customer client instead of quote ? And I don’t understand how container (dependency container?) appears to have a quoteTransfer linked to it.. How is this connected with the original question?

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

    Sorry.
    All QuoteClients I've seen so far (QuoteTransfer) are containing a customer.
    I added the function

    protected function addQuoteClient($container): Container
        {
            $container[static::CLIENT_QUOTE] = function (Container $container) {
                return new PriceProductToQuoteClientBridge($container->getLocator()->quote()->client());
            };
    
            return $container;
        }
    

    to src/Pyz/Zed/PriceProduct/PriceProductDependencyProvider.php. I thought I could access the customer in this QuoteTransfer (and resolve it by customerClient.. or request it directly, I am in Zed already). By this, I could receive the Company with its own margin