示例#1
0
 /**
  * Create new customer
  *
  * POST /api/customers
  */
 public function postAction()
 {
     $customer = $this->resource->create($this->Request()->getPost());
     $location = $this->apiBaseUrl . 'customers/' . $customer->getId();
     $data = array('id' => $customer->getId(), 'location' => $location);
     $this->View()->assign(array('success' => true, 'data' => $data));
     $this->Response()->setHeader('Location', $location);
 }
示例#2
0
 /**
  * Create dummy customer entity
  *
  * @return \Shopware\Models\Customer\Customer
  */
 private function createDummyCustomer()
 {
     $date = new DateTime();
     $date->modify('-8 days');
     $lastLogin = $date->format(DateTime::ISO8601);
     $birthday = DateTime::createFromFormat('Y-m-d', '1986-12-20')->format(DateTime::ISO8601);
     $testData = array("password" => "fooobar", "email" => uniqid() . '*****@*****.**', "lastlogin" => $lastLogin, "billing" => array("firstName" => "Max", "lastName" => "Mustermann", "birthday" => $birthday, "attribute" => array('text1' => 'Freitext1', 'text2' => 'Freitext2'), "zipcode" => '12345', "countryId" => '2'), "shipping" => array("salutation" => "Mr", "company" => "Widgets Inc.", "firstName" => "Max", "lastName" => "Mustermann", "street" => "Merkel Strasse, 10", "attribute" => array('text1' => 'Freitext1', 'text2' => 'Freitext2')), "debit" => array("account" => "Fake Account", "bankCode" => "55555555", "bankName" => "Fake Bank", "accountHolder" => "Max Mustermann"));
     $customerResource = new \Shopware\Components\Api\Resource\Customer();
     $customerResource->setManager(Shopware()->Models());
     return $customerResource->create($testData);
 }