71 private $collectionProcessor;
103 $this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
115 $addressModel =
null;
116 $customerModel = $this->customerRegistry->retrieve(
$address->getCustomerId());
118 $addressModel = $this->addressRegistry->retrieve(
$address->getId());
121 if ($addressModel ===
null) {
123 $addressModel = $this->addressFactory->create();
124 $addressModel->updateData(
$address);
125 $addressModel->setCustomer($customerModel);
127 $addressModel->updateData(
$address);
129 $addressModel->setStoreId($customerModel->getStoreId());
131 $errors = $addressModel->validate();
133 $inputException =
new InputException();
135 $inputException->addError($error);
137 throw $inputException;
139 $addressModel->save();
140 $address->setId($addressModel->getId());
143 $this->addressRegistry->push($addressModel);
144 $this->updateAddressCollection($customerModel, $addressModel);
146 return $addressModel->getDataModel();
172 $address = $this->addressRegistry->retrieve($addressId);
186 $collection = $this->addressCollectionFactory->create();
187 $this->extensionAttributesJoinProcessor->process(
202 $searchResults = $this->addressSearchResultsFactory->create();
205 $searchResults->setTotalCount(
$collection->getSize());
206 return $searchResults;
222 foreach ($filterGroup->
getFilters() as $filter) {
223 $condition = $filter->getConditionType() ? $filter->getConditionType() :
'eq';
224 $fields[] = [
'attribute' => $filter->getField(), $condition => $filter->getValue()];
225 $conditions[] = [$condition => $filter->getValue()];
242 $address = $this->addressRegistry->retrieve($addressId);
243 $customerModel = $this->customerRegistry->retrieve(
$address->getCustomerId());
244 $customerModel->getAddressesCollection()->clear();
245 $this->addressResourceModel->delete(
$address);
246 $this->addressRegistry->remove($addressId);
260 $address = $this->addressRegistry->retrieve($addressId);
261 $customerModel = $this->customerRegistry->retrieve(
$address->getCustomerId());
262 $customerModel->getAddressesCollection()->removeItemByKey($addressId);
263 $this->addressResourceModel->delete(
$address);
264 $this->addressRegistry->remove($addressId);
274 private function getCollectionProcessor()
276 if (!$this->collectionProcessor) {
278 'Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor' 281 return $this->collectionProcessor;
$extensionAttributesJoinProcessor
__construct(\Magento\Customer\Model\AddressFactory $addressFactory, \Magento\Customer\Model\AddressRegistry $addressRegistry, \Magento\Customer\Model\CustomerRegistry $customerRegistry, \Magento\Customer\Model\ResourceModel\Address $addressResourceModel, \Magento\Directory\Helper\Data $directoryData, \Magento\Customer\Api\Data\AddressSearchResultsInterfaceFactory $addressSearchResultsFactory, \Magento\Customer\Model\ResourceModel\Address\CollectionFactory $addressCollectionFactory, \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor, CollectionProcessorInterface $collectionProcessor=null)
save(\Magento\Customer\Api\Data\AddressInterface $address)
$addressSearchResultsFactory
$addressCollectionFactory
addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)