Collection.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Model\ResourceModel\Address;
  7. /**
  8. * Customers collection
  9. *
  10. * @api
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @since 100.0.2
  13. */
  14. class Collection extends \Magento\Eav\Model\Entity\Collection\VersionControl\AbstractCollection
  15. {
  16. /**
  17. * Resource initialization
  18. *
  19. * @return void
  20. */
  21. protected function _construct()
  22. {
  23. $this->_init(\Magento\Customer\Model\Address::class, \Magento\Customer\Model\ResourceModel\Address::class);
  24. }
  25. /**
  26. * Set customer filter
  27. *
  28. * @param \Magento\Customer\Model\Customer|array $customer
  29. * @return $this
  30. */
  31. public function setCustomerFilter($customer)
  32. {
  33. if (is_array($customer)) {
  34. $this->addAttributeToFilter('parent_id', ['in' => $customer]);
  35. } elseif ($customer->getId()) {
  36. $this->addAttributeToFilter('parent_id', $customer->getId());
  37. } else {
  38. $this->addAttributeToFilter('parent_id', '-1');
  39. }
  40. return $this;
  41. }
  42. }