Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function getAddresses()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAddresses', array());
     return parent::getAddresses();
 }
Ejemplo n.º 2
0
 /**
  * Merge profile with another profile
  *
  * @param \XLite\Model\Profile $profile Profile
  * @param integer              $flag    Peration flag OPTIONAL
  *
  * @return integer
  */
 public function mergeWithProfile(\XLite\Model\Profile $profile, $flag = self::MERGE_ALL)
 {
     $result = 0;
     // Addresses
     if ($flag & static::MERGE_ADDRESSES) {
         foreach ($profile->getAddresses() as $address) {
             $found = false;
             foreach ($this->getAddresses() as $a) {
                 if ($a->isEqualAddress($address)) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $address = $address->cloneEntity();
                 $this->addAddresses($address);
                 $address->setProfile($this);
             }
         }
         $result |= static::MERGE_ADDRESSES;
     }
     // Orders
     if ($flag & static::MERGE_ORDERS) {
         $cnd = new \XLite\Core\CommonCell();
         $cnd->profile = $profile;
         foreach (\XLite\Core\Database::getRepo('XLite\\Model\\Order')->search($cnd) as $order) {
             $order->setOrigProfile($this);
         }
         $result |= static::MERGE_ORDERS;
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Import address
  *
  * @param \XLite\Model\Profile $model   Profile
  * @param array                $address Address
  * @param integer              $index   Index
  *
  * @return void
  */
 protected function importAddress(\XLite\Model\Profile $model, array $address, $index)
 {
     $addr = $model->getAddresses()->get($index);
     if (!$addr) {
         $addr = $this->createAddress();
         $model->addAddresses($addr);
         $addr->setProfile($model);
     }
     if (isset($address['is_shipping'])) {
         $address['is_shipping'] = $this->normalizeValueAsBoolean($address['is_shipping']);
     }
     if (isset($address['is_billing'])) {
         $address['is_billing'] = $this->normalizeValueAsBoolean($address['is_billing']);
     }
     if (isset($address['state'])) {
         $address['state'] = $this->normalizeValueAsState($address['state']);
     }
     $this->updateAddress($addr, $address);
 }