Customer.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Model\Data;
  7. use \Magento\Framework\Api\AttributeValueFactory;
  8. /**
  9. * Class Customer
  10. * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  11. */
  12. class Customer extends \Magento\Framework\Api\AbstractExtensibleObject implements
  13. \Magento\Customer\Api\Data\CustomerInterface
  14. {
  15. /**
  16. * @var \Magento\Customer\Api\CustomerMetadataInterface
  17. */
  18. protected $metadataService;
  19. /**
  20. * Initialize dependencies.
  21. *
  22. * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  23. * @param AttributeValueFactory $attributeValueFactory
  24. * @param \Magento\Customer\Api\CustomerMetadataInterface $metadataService
  25. * @param array $data
  26. */
  27. public function __construct(
  28. \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
  29. AttributeValueFactory $attributeValueFactory,
  30. \Magento\Customer\Api\CustomerMetadataInterface $metadataService,
  31. $data = []
  32. ) {
  33. $this->metadataService = $metadataService;
  34. parent::__construct($extensionFactory, $attributeValueFactory, $data);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. protected function getCustomAttributesCodes()
  40. {
  41. if ($this->customAttributesCodes === null) {
  42. $this->customAttributesCodes = $this->getEavAttributesCodes($this->metadataService);
  43. }
  44. return $this->customAttributesCodes;
  45. }
  46. /**
  47. * @return string|null
  48. */
  49. public function getDefaultBilling()
  50. {
  51. return $this->_get(self::DEFAULT_BILLING);
  52. }
  53. /**
  54. * Get default shipping address id
  55. *
  56. * @return string|null
  57. */
  58. public function getDefaultShipping()
  59. {
  60. return $this->_get(self::DEFAULT_SHIPPING);
  61. }
  62. /**
  63. * Get confirmation
  64. *
  65. * @return string|null
  66. */
  67. public function getConfirmation()
  68. {
  69. return $this->_get(self::CONFIRMATION);
  70. }
  71. /**
  72. * Get created at time
  73. *
  74. * @return string|null
  75. */
  76. public function getCreatedAt()
  77. {
  78. return $this->_get(self::CREATED_AT);
  79. }
  80. /**
  81. * Get created in area
  82. *
  83. * @return string|null
  84. */
  85. public function getCreatedIn()
  86. {
  87. return $this->_get(self::CREATED_IN);
  88. }
  89. /**
  90. * Get updated at time
  91. *
  92. * @return string|null
  93. */
  94. public function getUpdatedAt()
  95. {
  96. return $this->_get(self::UPDATED_AT);
  97. }
  98. /**
  99. * Get date of birth
  100. *
  101. * @return string|null
  102. */
  103. public function getDob()
  104. {
  105. return $this->_get(self::DOB);
  106. }
  107. /**
  108. * Get email address
  109. *
  110. * @return string
  111. */
  112. public function getEmail()
  113. {
  114. return $this->_get(self::EMAIL);
  115. }
  116. /**
  117. * Get first name
  118. *
  119. * @return string
  120. */
  121. public function getFirstname()
  122. {
  123. return $this->_get(self::FIRSTNAME);
  124. }
  125. /**
  126. * Get gender
  127. *
  128. * @return string|null
  129. */
  130. public function getGender()
  131. {
  132. return $this->_get(self::GENDER);
  133. }
  134. /**
  135. * Get group id
  136. *
  137. * @return string|null
  138. */
  139. public function getGroupId()
  140. {
  141. return $this->_get(self::GROUP_ID);
  142. }
  143. /**
  144. * Get customer id
  145. *
  146. * @return int|null
  147. */
  148. public function getId()
  149. {
  150. return $this->_get(self::ID);
  151. }
  152. /**
  153. * Get last name
  154. *
  155. * @return string
  156. */
  157. public function getLastname()
  158. {
  159. return $this->_get(self::LASTNAME);
  160. }
  161. /**
  162. * Get middle name
  163. *
  164. * @return string|null
  165. */
  166. public function getMiddlename()
  167. {
  168. return $this->_get(self::MIDDLENAME);
  169. }
  170. /**
  171. * Get prefix
  172. *
  173. * @return string|null
  174. */
  175. public function getPrefix()
  176. {
  177. return $this->_get(self::PREFIX);
  178. }
  179. /**
  180. * Get store id
  181. *
  182. * @return int|null
  183. */
  184. public function getStoreId()
  185. {
  186. return $this->_get(self::STORE_ID);
  187. }
  188. /**
  189. * Get suffix
  190. *
  191. * @return string|null
  192. */
  193. public function getSuffix()
  194. {
  195. return $this->_get(self::SUFFIX);
  196. }
  197. /**
  198. * Get tax Vat.
  199. *
  200. * @return string|null
  201. */
  202. public function getTaxvat()
  203. {
  204. return $this->_get(self::TAXVAT);
  205. }
  206. /**
  207. * Get website id
  208. *
  209. * @return int|null
  210. */
  211. public function getWebsiteId()
  212. {
  213. return $this->_get(self::WEBSITE_ID);
  214. }
  215. /**
  216. * Get addresses
  217. *
  218. * @return \Magento\Customer\Api\Data\AddressInterface[]|null
  219. */
  220. public function getAddresses()
  221. {
  222. return $this->_get(self::KEY_ADDRESSES);
  223. }
  224. /**
  225. * Get disable auto group change flag.
  226. *
  227. * @return int|null
  228. */
  229. public function getDisableAutoGroupChange()
  230. {
  231. return $this->_get(self::DISABLE_AUTO_GROUP_CHANGE);
  232. }
  233. /**
  234. * Set customer id
  235. *
  236. * @param int $id
  237. * @return $this
  238. */
  239. public function setId($id)
  240. {
  241. return $this->setData(self::ID, $id);
  242. }
  243. /**
  244. * Set group id
  245. *
  246. * @param int $groupId
  247. * @return $this
  248. */
  249. public function setGroupId($groupId)
  250. {
  251. return $this->setData(self::GROUP_ID, $groupId);
  252. }
  253. /**
  254. * Set default billing address id
  255. *
  256. * @param string $defaultBilling
  257. * @return $this
  258. */
  259. public function setDefaultBilling($defaultBilling)
  260. {
  261. return $this->setData(self::DEFAULT_BILLING, $defaultBilling);
  262. }
  263. /**
  264. * Set default shipping address id
  265. *
  266. * @param string $defaultShipping
  267. * @return $this
  268. */
  269. public function setDefaultShipping($defaultShipping)
  270. {
  271. return $this->setData(self::DEFAULT_SHIPPING, $defaultShipping);
  272. }
  273. /**
  274. * Set confirmation
  275. *
  276. * @param string $confirmation
  277. * @return $this
  278. */
  279. public function setConfirmation($confirmation)
  280. {
  281. return $this->setData(self::CONFIRMATION, $confirmation);
  282. }
  283. /**
  284. * Set created at time
  285. *
  286. * @param string $createdAt
  287. * @return $this
  288. */
  289. public function setCreatedAt($createdAt)
  290. {
  291. return $this->setData(self::CREATED_AT, $createdAt);
  292. }
  293. /**
  294. * Set updated at time
  295. *
  296. * @param string $updatedAt
  297. * @return $this
  298. */
  299. public function setUpdatedAt($updatedAt)
  300. {
  301. return $this->setData(self::UPDATED_AT, $updatedAt);
  302. }
  303. /**
  304. * Set created in area
  305. *
  306. * @param string $createdIn
  307. * @return $this
  308. */
  309. public function setCreatedIn($createdIn)
  310. {
  311. return $this->setData(self::CREATED_IN, $createdIn);
  312. }
  313. /**
  314. * Set date of birth
  315. *
  316. * @param string $dob
  317. * @return $this
  318. */
  319. public function setDob($dob)
  320. {
  321. return $this->setData(self::DOB, $dob);
  322. }
  323. /**
  324. * Set email address
  325. *
  326. * @param string $email
  327. * @return $this
  328. */
  329. public function setEmail($email)
  330. {
  331. return $this->setData(self::EMAIL, $email);
  332. }
  333. /**
  334. * Set first name
  335. *
  336. * @param string $firstname
  337. * @return $this
  338. */
  339. public function setFirstname($firstname)
  340. {
  341. return $this->setData(self::FIRSTNAME, $firstname);
  342. }
  343. /**
  344. * Set last name
  345. *
  346. * @param string $lastname
  347. * @return string
  348. */
  349. public function setLastname($lastname)
  350. {
  351. return $this->setData(self::LASTNAME, $lastname);
  352. }
  353. /**
  354. * Set middle name
  355. *
  356. * @param string $middlename
  357. * @return $this
  358. */
  359. public function setMiddlename($middlename)
  360. {
  361. return $this->setData(self::MIDDLENAME, $middlename);
  362. }
  363. /**
  364. * Set prefix
  365. *
  366. * @param string $prefix
  367. * @return $this
  368. */
  369. public function setPrefix($prefix)
  370. {
  371. return $this->setData(self::PREFIX, $prefix);
  372. }
  373. /**
  374. * Set suffix
  375. *
  376. * @param string $suffix
  377. * @return $this
  378. */
  379. public function setSuffix($suffix)
  380. {
  381. return $this->setData(self::SUFFIX, $suffix);
  382. }
  383. /**
  384. * Set gender
  385. *
  386. * @param string $gender
  387. * @return $this
  388. */
  389. public function setGender($gender)
  390. {
  391. return $this->setData(self::GENDER, $gender);
  392. }
  393. /**
  394. * Set store id
  395. *
  396. * @param int $storeId
  397. * @return $this
  398. */
  399. public function setStoreId($storeId)
  400. {
  401. return $this->setData(self::STORE_ID, $storeId);
  402. }
  403. /**
  404. * Set tax Vat
  405. *
  406. * @param string $taxvat
  407. * @return $this
  408. */
  409. public function setTaxvat($taxvat)
  410. {
  411. return $this->setData(self::TAXVAT, $taxvat);
  412. }
  413. /**
  414. * Set website id
  415. *
  416. * @param int $websiteId
  417. * @return $this
  418. */
  419. public function setWebsiteId($websiteId)
  420. {
  421. return $this->setData(self::WEBSITE_ID, $websiteId);
  422. }
  423. /**
  424. * Set customer addresses.
  425. *
  426. * @param \Magento\Customer\Api\Data\AddressInterface[] $addresses
  427. * @return $this
  428. */
  429. public function setAddresses(array $addresses = null)
  430. {
  431. return $this->setData(self::KEY_ADDRESSES, $addresses);
  432. }
  433. /**
  434. * Set disable auto group change flag.
  435. *
  436. * @param int $disableAutoGroupChange
  437. * @return $this
  438. */
  439. public function setDisableAutoGroupChange($disableAutoGroupChange)
  440. {
  441. return $this->setData(self::DISABLE_AUTO_GROUP_CHANGE, $disableAutoGroupChange);
  442. }
  443. /**
  444. * {@inheritdoc}
  445. *
  446. * @return \Magento\Customer\Api\Data\CustomerExtensionInterface|null
  447. */
  448. public function getExtensionAttributes()
  449. {
  450. return $this->_getExtensionAttributes();
  451. }
  452. /**
  453. * {@inheritdoc}
  454. *
  455. * @param \Magento\Customer\Api\Data\CustomerExtensionInterface $extensionAttributes
  456. * @return $this
  457. */
  458. public function setExtensionAttributes(\Magento\Customer\Api\Data\CustomerExtensionInterface $extensionAttributes)
  459. {
  460. return $this->_setExtensionAttributes($extensionAttributes);
  461. }
  462. }