Пример #1
0
 /**
  * @param \Propel\Runtime\Collection\ObjectCollection $entities
  * @param \Orm\Zed\Customer\Persistence\SpyCustomer $customer
  *
  * @return \Generated\Shared\Transfer\AddressesTransfer
  */
 protected function entityCollectionToTransferCollection(ObjectCollection $entities, SpyCustomer $customer)
 {
     $addressCollection = new AddressesTransfer();
     foreach ($entities->getData() as $address) {
         $addressTransfer = $this->entityToTransfer($address);
         if ($customer->getDefaultBillingAddress() === $address->getIdCustomerAddress()) {
             $addressTransfer->setIsDefaultBilling(true);
         }
         if ($customer->getDefaultShippingAddress() === $address->getIdCustomerAddress()) {
             $addressTransfer->setIsDefaultShipping(true);
         }
         $addressCollection->addAddress($addressTransfer);
     }
     return $addressCollection;
 }
Пример #2
0
 /**
  * @param \Generated\Shared\Transfer\AddressTransfer $addressTransfer
  * @param \Orm\Zed\Customer\Persistence\SpyCustomer $customerEntity
  *
  * @return void
  */
 protected function updateCustomerDefaultAddresses(AddressTransfer $addressTransfer, SpyCustomer $customerEntity)
 {
     if ($customerEntity->getDefaultBillingAddress() === null || $addressTransfer->getIsDefaultBilling()) {
         $customerEntity->setDefaultBillingAddress($addressTransfer->getIdCustomerAddress());
     }
     if ($customerEntity->getDefaultShippingAddress() === null || $addressTransfer->getIsDefaultShipping()) {
         $customerEntity->setDefaultShippingAddress($addressTransfer->getIdCustomerAddress());
     }
     $customerEntity->save();
 }