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 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?

  • 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 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?

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

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

  • giovanni.piemontese
    giovanni.piemontese 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?

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    sue me

  • U01G4K5E0J2
    U01G4K5E0J2 Posts: 194 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    ๐Ÿ˜‰

  • giovanni.piemontese
    giovanni.piemontese 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.