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'm trying to update an order ```$order = new OrderTransfer(); $order->setEmail('

U01G4K5E0J2
U01G4K5E0J2 Posts: 194 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi,
I'm trying to update an order

$order = new OrderTransfer();
$order->setEmail('<mailto:steve.rogers@example.org|steve.rogers@example.org>');
/** @var SalesFacadeInterface $salesFacade **/
$salesFacade->updateOrder($order, $orderId);

and I get

Call to a member function getTaxTotal() on null

because during this update OrderUpdater wants to create order totals

    protected function createOrderTotals(OrderTransfer $orderTransfer, SpySalesOrder $orderEntity)
    {
        $taxTotal = 0;
        if ($orderTransfer->getTotals()->getTaxTotal()) {
            $taxTotal = $orderTransfer->getTotals()->getTaxTotal()->getAmount();
        }
...

am I doing something wrong or missing something?

Comments

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    That updateOrder() method is not prepared to only process adjusted properties imo. So it runs though the update stack that contains lots of different aspects, like the one you encountered.

    It might be easier (necessary) to create your own custom facade method to cover the particular use case

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    The error itself happens as getTotals() on OrderTransfer returns null instead of another TransferObject, as you did not populate it. You couuuuuuld try to create an empty one (TotalsTransfer? not sure) and try once more. But I feel even if it would work at the moment, the risk of this breaking at some point is… too big

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    Why u want update an order entity in this form? Can u please explain what is your goal?

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 πŸ§‘πŸ»β€πŸš€ - Cadet

    I dont see why not

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 πŸ§‘πŸ»β€πŸš€ - Cadet

    scrambling email and deleting all other user related data, just as CustomerFacade::anonymizeCustomer does

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 πŸ§‘πŸ»β€πŸš€ - Cadet

    but I've already figured out how to do that

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    There’s always some project with some expectations. I think that updateOrder is just not aimed to cover such cases

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    you could create your own scrambleUserData($orderId) that internally is passing by the existing OrderFacade’s capabilities

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ah ok, so already figured out a way. Which way did you chose? πŸ™‚

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    I thing that the clean way is this to manage via oms. When u want to do it?

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 πŸ§‘πŸ»β€πŸš€ - Cadet

    pulled orders from a query and updated entities, like a caveman πŸ˜‰

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    Oh no please. Why not update the customer data fields with a command by order in oms state machine?

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 πŸ§‘πŸ»β€πŸš€ - Cadet

    sue me

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 πŸ§‘πŸ»β€πŸš€ - Cadet

    πŸ˜‰

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    There u have the whole order entity and u have just to run your business logic and stop.