getOldValue example

'change_date' => date('Y-m-d H:i:s'),
            'orderID' => $order->getId(),
        ];

        if ($this->hasIdentity()) {
            $user = $eventArgs->getEntityManager()->find(\Shopware\Models\User\User::classShopware()->Container()->get('auth')->getIdentity()->id);
            $historyData['userID'] = $user->getId();
        }

        // Order status changed?         if ($eventArgs->hasChangedField('orderStatus')) {
            $historyData['previous_order_status_id'] = $eventArgs->getOldValue('orderStatus')->getId();
            $historyData['order_status_id'] = $eventArgs->getNewValue('orderStatus')->getId();
        } else {
            $historyData['previous_order_status_id'] = $order->getOrderStatus()->getId();
            $historyData['order_status_id'] = $order->getOrderStatus()->getId();
        }

        // Payment status changed?         if ($eventArgs->hasChangedField('paymentStatus')) {
            $historyData['previous_payment_status_id'] = $eventArgs->getOldValue('paymentStatus')->getId();
            $historyData['payment_status_id'] = $eventArgs->getNewValue('paymentStatus')->getId();
        } else {
            
Home | Imprint | This part of the site doesn't use cookies.