Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function _afterDelete(\Magento\Framework\DataObject $address)
 {
     if ($address->getId()) {
         $customer = $this->customerRepository->getById($address->getCustomerId());
         if ($customer->getDefaultBilling() == $address->getId()) {
             $customer->setDefaultBilling(null);
         }
         if ($customer->getDefaultShipping() == $address->getId()) {
             $customer->setDefaultShipping(null);
         }
         $this->customerRepository->save($customer);
     }
     return parent::_afterDelete($address);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 protected function _afterDelete(\Magento\Framework\Object $address)
 {
     if ($address->getId()) {
         $customer = $this->_createCustomer()->load($address->getCustomerId());
         if ($customer->getDefaultBilling() == $address->getId()) {
             $customer->setDefaultBilling(null);
         }
         if ($customer->getDefaultShipping() == $address->getId()) {
             $customer->setDefaultShipping(null);
         }
         $customer->save();
     }
     return parent::_afterDelete($address);
 }