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('

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?

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • 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

  • 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

  • Technical Lead @ LΓΆffelhardt Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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

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

    I dont see why not

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

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

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

    but I've already figured out how to do that

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

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

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

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

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

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

  • Technical Lead @ LΓΆffelhardt Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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

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

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

  • Technical Lead @ LΓΆffelhardt 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?

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

    sue me

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

    πŸ˜‰

  • Technical Lead @ LΓΆffelhardt Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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

Welcome!

It looks like you're new here. Sign in or register to get started.