\Shopware\Components\Api\ResourceEcustomer

Customer API Resource.

Performs all the API operations on Customer records. Extends Shopwares REST API Customer.

Summary

Methods
Properties
Constants
getRepository()
getIdFromNumber()
getOneByNumber()
getOne()
getList()
create()
updateByNumber()
update()
deleteByNumber()
delete()
isEmailUnique()
No public properties found
No constants found
prepareAssociatedData()
prepareCustomerAddressData()
prepareCustomerPaymentData()
No protected properties found
N/A
prepareCustomerData()
No private properties found
N/A

Methods

getRepository()

getRepository() : \Shopware\Models\Customer\Repository

Loads repository class for the Customer resource.

Returns

\Shopware\Models\Customer\Repository

getIdFromNumber()

getIdFromNumber(string  $number) : integer

Little helper function for the getOneByNumber method.

Gets the Customer id from the Customer number.

Parameters

string $number

Customer number to get its Id.

Throws

\Shopware\Components\Api\Exception\NotFoundException
\Shopware\Components\Api\Exception\ParameterMissingException

Returns

integer

getOneByNumber()

getOneByNumber(string  $number) : array|\Shopware\Models\Customer\Customer

Fetches Customer details based on Customer number.

Parameters

string $number

Customer number to get its details.

Throws

\Shopware\Components\Api\Exception\ParameterMissingException
\Shopware\Components\Api\Exception\NotFoundException

Returns

array|\Shopware\Models\Customer\Customer

getOne()

getOne(integer  $id) : array|\Shopware\Models\Customer\Customer

Fetches Customer details based on Customer Id.

Parameters

integer $id

Customer Id to get its details.

Throws

\Shopware\Components\Api\Exception\ParameterMissingException
\Shopware\Components\Api\Exception\NotFoundException

Returns

array|\Shopware\Models\Customer\Customer

getList()

getList(integer  $offset, integer  $limit = 25, array  $criteria = array(), array  $orderBy = array()) : array

Fetches all the Customer details.

Parameters

integer $offset

offset to fetch the Customer list.

integer $limit

limit to fetch the Customer list.

array $criteria

criteria to fetch the Customer list.

array $orderBy

orderby field to fetch the Customer list in a specified order.

Returns

array

create()

create(array  $params) : \Shopware\Models\Customer\Customer

Creates a new Customer record.

Parameters

array $params

data for the Customer to be created.

Throws

\Shopware\Components\Api\Exception\CustomValidationException
\Shopware\Components\Api\Exception\ValidationException
\Exception

Returns

\Shopware\Models\Customer\Customer

updateByNumber()

updateByNumber(string  $number, array  $params) : \Shopware\Models\Customer\Customer

Updates Customer details based on Customer number.

Parameters

string $number

Customer number to update its details.

array $params

data to be updated.

Throws

\Shopware\Components\Api\Exception\ValidationException
\Shopware\Components\Api\Exception\NotFoundException
\Shopware\Components\Api\Exception\ParameterMissingException
\Shopware\Components\Api\Exception\CustomValidationException

Returns

\Shopware\Models\Customer\Customer

update()

update(integer  $id, array  $params) : \Shopware\Models\Customer\Customer

Updates Customer details based on Customer Id.

Parameters

integer $id

Customer Id to update its details.

array $params

data to be updated.

Throws

\Shopware\Components\Api\Exception\ValidationException
\Shopware\Components\Api\Exception\NotFoundException
\Shopware\Components\Api\Exception\ParameterMissingException
\Shopware\Components\Api\Exception\CustomValidationException

Returns

\Shopware\Models\Customer\Customer

deleteByNumber()

deleteByNumber(string  $number) : \Shopware\Models\Customer\Customer

Deletes Customer details based on Customer number.

Parameters

string $number

Customer number to delete its details.

Throws

\Shopware\Components\Api\Exception\ParameterMissingException
\Shopware\Components\Api\Exception\NotFoundException

Returns

\Shopware\Models\Customer\Customer

delete()

delete(integer  $id) : \Shopware\Models\Customer\Customer

Deletes Customer details based on Customer Id.

Parameters

integer $id

Customer Id to delete its details.

Throws

\Shopware\Components\Api\Exception\ParameterMissingException
\Shopware\Components\Api\Exception\NotFoundException

Returns

\Shopware\Models\Customer\Customer

isEmailUnique()

isEmailUnique(  $mail, null|\Shopware\Models\Customer\Customer  $customer = null, null|integer  $shopId = null) : boolean

Checks customers email id is unique or not before inserting/updating.

Parameters

$mail
null|\Shopware\Models\Customer\Customer $customer
null|integer $shopId

Returns

boolean

prepareAssociatedData()

prepareAssociatedData(  $data, \Shopware\Models\Customer\Customer  $customer) : array

Helper method to prepare the Customer additional data.

Parameters

$data
\Shopware\Models\Customer\Customer $customer

Throws

\Shopware\Components\Api\Exception\CustomValidationException

Returns

array

prepareCustomerAddressData()

prepareCustomerAddressData(array  $data) : array

Helper method to prepare the Customer address data.

Merges streetNumber into street in billing and shipping addresses If no street is provided, streetNumber is dropped

Parameters

array $data

Data to be formatted/prepared.

Returns

array

prepareCustomerPaymentData()

prepareCustomerPaymentData(array  $data, \Shopware\Models\Customer\Customer  $customer) : array

Helper method to prepare the Customer payment data.

Parameters

array $data

Data to be formatted/prepared.

\Shopware\Models\Customer\Customer $customer

Throws

\Shopware\Components\Api\Exception\CustomValidationException

Returns

array

prepareCustomerData()

prepareCustomerData(array  $params,   $customer = null) : array

Helper method to prepare the Customer data.

Parameters

array $params

Data to be formatted/prepared.

$customer

Throws

\Shopware\Components\Api\Exception\CustomValidationException

Returns

array