/** * get customer list * @param $site_srl * @param array $extraParams * @return array * @throws ShopException */ public function getCustomersList($site_srl, array $extraParams = array()) { if (!$site_srl) { throw new ShopException("Missing arguments for get customers list : please provide [site_srl]"); } $addressRepository = new AddressRepository(); $page = Context::get('page') ? Context::get('page') : 1; $output = $this->getSiteMemberList($site_srl, $page, $extraParams); foreach ($output->data as $member) { $customer = new Customer($member); $customer->addresses = $addressRepository->getAddresses($customer->member_srl); $customer->telephone = $customer->addresses->default_billing->telephone; $customer->postal_code = $customer->addresses->default_billing->postal_code; $customer->country = $customer->addresses->default_billing->country; $customer->region = $customer->addresses->default_billing->region; $extra_vars = unserialize($member->extra_vars); $customer->newsletter = $extra_vars->newsletter; $customers[] = $customer; } $output->customers = $customers; return $output; }
public function getAddresses($refresh = false) { if (!is_array($this->addresses) || ($refresh = true)) { if (!$this->member_srl) { $addresses = array(); if ($this->billing_address_srl) { $addresses[] = $this->getBillingAddress(); } if ($this->shipping_address_srl && $this->billing_address_srl != $this->shipping_address_srl) { $addresses[] = $this->getShippingAddress(); } return $addresses; } $aRepo = new AddressRepository(); $this->addresses = $aRepo->getAddresses($this->member_srl, true); } return $this->addresses; }