コード例 #1
0
ファイル: AddressRepository.php プロジェクト: nja78/magento2
 /**
  * Retrieve customers addresses matching the specified criteria.
  *
  * @param SearchCriteriaInterface $searchCriteria
  * @return \Magento\Customer\Api\Data\AddressSearchResultsInterface
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function getList(SearchCriteriaInterface $searchCriteria)
 {
     $searchResults = $this->addressSearchResultsFactory->create();
     /** @var Collection $collection */
     $collection = $this->addressCollectionFactory->create();
     $this->extensionAttributesJoinProcessor->process($collection, 'Magento\\Customer\\Api\\Data\\AddressInterface');
     // Add filters from root filter group to the collection
     foreach ($searchCriteria->getFilterGroups() as $group) {
         $this->addFilterGroupToCollection($group, $collection);
     }
     $searchResults->setTotalCount($collection->getSize());
     /** @var SortOrder $sortOrder */
     foreach ((array) $searchCriteria->getSortOrders() as $sortOrder) {
         $field = $sortOrder->getField();
         $collection->addOrder($field, $sortOrder->getDirection() == SearchCriteriaInterface::SORT_ASC ? 'ASC' : 'DESC');
     }
     $collection->setCurPage($searchCriteria->getCurrentPage());
     $collection->setPageSize($searchCriteria->getPageSize());
     /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
     $addresses = [];
     /** @var \Magento\Customer\Model\Address $address */
     foreach ($collection->getItems() as $address) {
         $addresses[] = $this->getById($address->getId());
     }
     $searchResults->setItems($addresses);
     $searchResults->setSearchCriteria($searchCriteria);
     return $searchResults;
 }
コード例 #2
0
ファイル: Address.php プロジェクト: nja78/magento2
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory
  * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory
  * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
  * @param \Magento\Eav\Model\Config $eavConfig
  * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerColFactory
  * @param \Magento\CustomerImportExport\Model\Export\CustomerFactory $eavCustomerFactory
  * @param \Magento\Customer\Model\Resource\Address\CollectionFactory $addressColFactory
  * @param array $data
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $eavConfig, \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerColFactory, \Magento\CustomerImportExport\Model\Export\CustomerFactory $eavCustomerFactory, \Magento\Customer\Model\Resource\Address\CollectionFactory $addressColFactory, array $data = [])
 {
     parent::__construct($scopeConfig, $storeManager, $collectionFactory, $resourceColFactory, $localeDate, $eavConfig, $data);
     $this->_customerCollection = isset($data['customer_collection']) ? $data['customer_collection'] : $customerColFactory->create();
     $this->_customerEntity = isset($data['customer_entity']) ? $data['customer_entity'] : $eavCustomerFactory->create();
     $this->_addressCollection = isset($data['address_collection']) ? $data['address_collection'] : $addressColFactory->create();
     $this->_initWebsites(true);
     $this->setFileName($this->getEntityTypeCode());
 }
コード例 #3
0
ファイル: Address.php プロジェクト: kid17/magento2
 /**
  * @param \Magento\Framework\Stdlib\String $string
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\ImportExport\Model\ImportFactory $importFactory
  * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory
  * @param \Magento\Eav\Model\Config $eavConfig
  * @param \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory
  * @param \Magento\Customer\Model\AddressFactory $addressFactory
  * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionColFactory
  * @param \Magento\Customer\Model\CustomerFactory $customerFactory
  * @param \Magento\Customer\Model\Resource\Address\CollectionFactory $addressColFactory
  * @param \Magento\Customer\Model\Resource\Address\Attribute\CollectionFactory $attributesFactory
  * @param \Magento\Framework\Stdlib\DateTime $dateTime
  * @param array $data
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\Stdlib\String $string, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory, \Magento\Customer\Model\AddressFactory $addressFactory, \Magento\Directory\Model\Resource\Region\CollectionFactory $regionColFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\Resource\Address\CollectionFactory $addressColFactory, \Magento\Customer\Model\Resource\Address\Attribute\CollectionFactory $attributesFactory, \Magento\Framework\Stdlib\DateTime $dateTime, array $data = [])
 {
     $this->_customerFactory = $customerFactory;
     $this->_addressFactory = $addressFactory;
     $this->_eavConfig = $eavConfig;
     $this->_resourceHelper = $resourceHelper;
     $this->dateTime = $dateTime;
     if (!isset($data['attribute_collection'])) {
         /** @var $attributeCollection \Magento\Customer\Model\Resource\Address\Attribute\Collection */
         $attributeCollection = $attributesFactory->create();
         $attributeCollection->addSystemHiddenFilter()->addExcludeHiddenFrontendFilter();
         $data['attribute_collection'] = $attributeCollection;
     }
     parent::__construct($string, $scopeConfig, $importFactory, $resourceHelper, $resource, $storeManager, $collectionFactory, $eavConfig, $storageFactory, $data);
     $this->_addressCollection = isset($data['address_collection']) ? $data['address_collection'] : $addressColFactory->create();
     $this->_entityTable = isset($data['entity_table']) ? $data['entity_table'] : $addressFactory->create()->getResource()->getEntityTable();
     $this->_regionCollection = isset($data['region_collection']) ? $data['region_collection'] : $regionColFactory->create();
     $this->addMessageTemplate(self::ERROR_ADDRESS_ID_IS_EMPTY, __('Customer address id column is not specified'));
     $this->addMessageTemplate(self::ERROR_ADDRESS_NOT_FOUND, __("Customer address for such customer doesn't exist"));
     $this->addMessageTemplate(self::ERROR_INVALID_REGION, __('Region is invalid'));
     $this->addMessageTemplate(self::ERROR_DUPLICATE_PK, __('Row with such email, website and address id combination was already found.'));
     $this->_initAttributes();
     $this->_initAddresses()->_initCountryRegions();
 }
コード例 #4
0
ファイル: Customer.php プロジェクト: nja78/magento2
 /**
  * @return \Magento\Customer\Model\Resource\Address\Collection
  */
 protected function _createAddressCollection()
 {
     return $this->_addressesFactory->create();
 }