Common/EventListener/AbstractSaleListener.php
public function onInitialize(ResourceEventInterface $event)
    {
        $sale = $this->getSaleFromEvent($event);

        if (null !== $customer = $sale->getCustomer()) {
            $invoiceDefault = $customer->getDefaultInvoiceAddress(true);
            $deliveryDefault = $customer->getDefaultDeliveryAddress(true);

            if (null === $sale->getInvoiceAddress() && null !== $invoiceDefault) {
                $sale->setInvoiceAddress(
                    $this->saleFactory->createAddressForSale($sale, $invoiceDefault)
                );
            }

            if (null === $sale->getDeliveryAddress() && null !== $deliveryDefault && $deliveryDefault !== $invoiceDefault) {
                $sale
                    ->setSameAddress(false)
                    ->setDeliveryAddress(
                        $this->saleFactory->createAddressForSale($sale, $invoiceDefault)
                    );
            }
        }
    }
public function onInitialize(ResourceEventInterface $event)
    {
        $sale = $this->getSaleFromEvent($event);

        if (null !== $customer = $sale->getCustomer()) {
            $invoiceDefault = $customer->getDefaultInvoiceAddress(true);
            $deliveryDefault = $customer->getDefaultDeliveryAddress(true);

            if (null === $sale->getInvoiceAddress() && null !== $invoiceDefault) {
                $sale->setInvoiceAddress(
                    $this->saleFactory->createAddressForSale($sale, $invoiceDefault)
                );
            }

            if (null === $sale->getDeliveryAddress() && null !== $deliveryDefault && $deliveryDefault !== $invoiceDefault) {
                $sale
                    ->setSameAddress(false)
                    ->setDeliveryAddress(
                        $this->saleFactory->createAddressForSale($sale, $invoiceDefault)
                    );
            }
        }
    }
public function onInitialize ( ResourceEventInterface $ event ) { $ sale = $ this -> getSaleFromEvent ( $ event ) ; if ( null !== $ customer = $ sale -> getCustomer ( ) ) { $ invoiceDefault = $ customer -> getDefaultInvoiceAddress ( true ) ; $ deliveryDefault = $ customer -> getDefaultDeliveryAddress ( true ) ; if ( null === $ sale -> getInvoiceAddress ( ) && null !== $ invoiceDefault ) { $ sale -> setInvoiceAddress ( $ this -> saleFactory -> createAddressForSale ( $ sale , $ invoiceDefault ) ) ; } if ( null === $ sale -> getDeliveryAddress ( ) && null !== $ deliveryDefault && $ deliveryDefault !== $ invoiceDefault ) { $ sale -> setSameAddress ( false ) -> setDeliveryAddress ( $ this -> saleFactory -> createAddressForSale ( $ sale , $ invoiceDefault ) ) ; } } }
Initialize event handler.

@param ResourceEventInterface $event
Initialize event handler .