当前位置: 首页>>代码示例>>PHP>>正文


PHP AddressRepositoryInterface::getList方法代码示例

本文整理汇总了PHP中Magento\Customer\Api\AddressRepositoryInterface::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP AddressRepositoryInterface::getList方法的具体用法?PHP AddressRepositoryInterface::getList怎么用?PHP AddressRepositoryInterface::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Customer\Api\AddressRepositoryInterface的用法示例。


在下文中一共展示了AddressRepositoryInterface::getList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * @return void
  */
 public function execute()
 {
     $filter = $this->filterBuilder->setField('parent_id')->setValue($this->_getCheckout()->getCustomer()->getId())->setConditionType('eq')->create();
     $addresses = (array) $this->addressRepository->getList($this->searchCriteriaBuilder->addFilters([$filter])->create())->getItems();
     /**
      * if we create first address we need reset emd init checkout
      */
     if (count($addresses) === 1) {
         $this->_getCheckout()->reset();
     }
     $this->_redirect('*/checkout/addresses');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:ShippingSaved.php

示例2: getAddress

 /**
  * Get a list of current customer addresses.
  *
  * @return \Magento\Customer\Api\Data\AddressInterface[]
  */
 public function getAddress()
 {
     $addresses = $this->getData('address_collection');
     if ($addresses === null) {
         try {
             $filter = $this->filterBuilder->setField('parent_id')->setValue($this->_multishipping->getCustomer()->getId())->setConditionType('eq')->create();
             $addresses = (array) $this->addressRepository->getList($this->searchCriteriaBuilder->addFilters([$filter])->create())->getItems();
         } catch (NoSuchEntityException $e) {
             return [];
         }
         $this->setData('address_collection', $addresses);
     }
     return $addresses;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Select.php

示例3: testSearchAddresses

 /**
  * @param \Magento\Framework\Api\Filter[] $filters
  * @param \Magento\Framework\Api\Filter[] $filterGroup
  * @param \Magento\Framework\Api\SortOrder[] $filterOrders
  * @param array $expectedResult array of expected results indexed by ID
  *
  * @dataProvider searchAddressDataProvider
  *
  * @magentoDataFixture  Magento/Customer/_files/customer.php
  * @magentoDataFixture  Magento/Customer/_files/customer_two_addresses.php
  * @magentoAppIsolation enabled
  */
 public function testSearchAddresses($filters, $filterGroup, $filterOrders, $expectedResult)
 {
     /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */
     $searchBuilder = $this->_objectManager->create('Magento\\Framework\\Api\\SearchCriteriaBuilder');
     foreach ($filters as $filter) {
         $searchBuilder->addFilters([$filter]);
     }
     if ($filterGroup !== null) {
         $searchBuilder->addFilters($filterGroup);
     }
     if ($filterOrders !== null) {
         foreach ($filterOrders as $order) {
             $searchBuilder->addSortOrder($order);
         }
     }
     $searchResults = $this->repository->getList($searchBuilder->create());
     $this->assertEquals(count($expectedResult), $searchResults->getTotalCount());
     $i = 0;
     /** @var \Magento\Customer\Api\Data\AddressInterface $item*/
     foreach ($searchResults->getItems() as $item) {
         $this->assertEquals($expectedResult[$i]['id'], $item->getId());
         $this->assertEquals($expectedResult[$i]['city'], $item->getCity());
         $this->assertEquals($expectedResult[$i]['postcode'], $item->getPostcode());
         $this->assertEquals($expectedResult[$i]['firstname'], $item->getFirstname());
         $i++;
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:39,代码来源:AddressRepositoryTest.php

示例4: getAddressCollection

 /**
  * Retrieve current customer address DATA collection.
  *
  * @return \Magento\Customer\Api\Data\AddressInterface[]
  */
 public function getAddressCollection()
 {
     if ($this->getCustomerId()) {
         $filter = $this->filterBuilder->setField('parent_id')->setValue($this->getCustomerId())->setConditionType('eq')->create();
         $this->searchCriteriaBuilder->addFilters([$filter]);
         $searchCriteria = $this->searchCriteriaBuilder->create();
         $result = $this->addressService->getList($searchCriteria);
         return $result->getItems();
     }
     return [];
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Address.php

示例5: getDefaultAddressByDataKey

 /**
  * Retrieve customer default address by data key
  *
  * @param string $key
  * @param string|null $defaultAddressIdFromCustomer
  * @return int|null
  */
 private function getDefaultAddressByDataKey($key, $defaultAddressIdFromCustomer)
 {
     $addressId = $this->getData($key);
     if (is_null($addressId)) {
         $addressId = $defaultAddressIdFromCustomer;
         if (!$addressId) {
             /** Default address is not available, try to find any customer address */
             $filter = $this->filterBuilder->setField('parent_id')->setValue($this->getCustomer()->getId())->setConditionType('eq')->create();
             $addresses = (array) $this->addressRepository->getList($this->searchCriteriaBuilder->addFilters([$filter])->create())->getItems();
             if ($addresses) {
                 $address = reset($addresses);
                 $addressId = $address->getId();
             }
         }
         $this->setData($key, $addressId);
     }
     return $addressId;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:Multishipping.php


注:本文中的Magento\Customer\Api\AddressRepositoryInterface::getList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。