Я пытаюсь создать клиента с помощью ресурса API. Я сделал команду (используется в терминале), которая использует диспетчер API, и с помощью метода ресурса клиента create()
я хочу создать клиента
$data = [
'email' => 'meier@mail.de',
'firstname' => 'Max',
'lastname' => 'Meier',
'salutation' => 'mr',
'billing' => [
'firstname' => 'Max',
'lastname' => 'Meier',
'salutation' => 'mr',
'street' => 'Musterstrasse 55',
'city' => 'Sch\\u00f6ppingen',
'zipcode' => '48624',
'country' => 2
],
];
$manager = new \ Shopware \ Components \ Api \ Manager ();
$customerManager = $manager->getResource('Customer');
$response = $customerManager->create($data);
// trying to check the response
echo "<pre>";
echo "";
print_r($response);
echo PHP_EOL;
die();
Но он получает эту ошибку:
So i added 'shopId' in the array above like this:
$data = [
'email' => 'meier@mail.de',
'firstname' => 'Max',
'lastname' => 'Meier',
'salutation' => 'mr',
'billing' => [
'firstname' => 'Max',
'lastname' => 'Meier',
'salutation' => 'mr',
'street' => 'Musterstrasse 55',
'city' => 'Sch\\u00f6ppingen',
'zipcode' => '48624',
'country' => 2,
],
'shopId' => 1
];
Now it does not give that error, but also does not create a customer. I also tried putting shopId
in string as well like this:
shopId' => '1'
but same result - not creating a customer.
What am i doing wrong? Any leads?
This is the documentation i followed:
https://developers.shopware.com/developers-guide/rest-api/examples/customer/?_ga=2.85949721.1456721681.1594287812-2015268552.1594287811#example -3-create-a-customer-account