Shipment.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order;
  7. use Magento\Framework\Api\AttributeValueFactory;
  8. use Magento\Sales\Api\Data\ShipmentInterface;
  9. use Magento\Sales\Model\AbstractModel;
  10. use Magento\Sales\Model\EntityInterface;
  11. use Magento\Sales\Model\ResourceModel\Order\Shipment\Comment\Collection as CommentsCollection;
  12. /**
  13. * Sales order shipment model
  14. *
  15. * @api
  16. * @method \Magento\Sales\Model\Order\Invoice setSendEmail(bool $value)
  17. * @method \Magento\Sales\Model\Order\Invoice setCustomerNote(string $value)
  18. * @method string getCustomerNote()
  19. * @method \Magento\Sales\Model\Order\Invoice setCustomerNoteNotify(bool $value)
  20. * @method bool getCustomerNoteNotify()
  21. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  22. * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  23. * @since 100.0.2
  24. */
  25. class Shipment extends AbstractModel implements EntityInterface, ShipmentInterface
  26. {
  27. const STATUS_NEW = 1;
  28. const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created';
  29. const REPORT_DATE_TYPE_SHIPMENT_CREATED = 'shipment_created';
  30. /**
  31. * Store address
  32. */
  33. const XML_PATH_STORE_ADDRESS1 = 'shipping/origin/street_line1';
  34. const XML_PATH_STORE_ADDRESS2 = 'shipping/origin/street_line2';
  35. const XML_PATH_STORE_CITY = 'shipping/origin/city';
  36. const XML_PATH_STORE_REGION_ID = 'shipping/origin/region_id';
  37. const XML_PATH_STORE_ZIP = 'shipping/origin/postcode';
  38. const XML_PATH_STORE_COUNTRY_ID = 'shipping/origin/country_id';
  39. /**
  40. * Order entity type
  41. *
  42. * @var string
  43. */
  44. protected $entityType = 'shipment';
  45. /**
  46. * @var \Magento\Sales\Model\Order
  47. */
  48. protected $_order;
  49. /**
  50. * @var string
  51. */
  52. protected $_eventPrefix = 'sales_order_shipment';
  53. /**
  54. * @var string
  55. */
  56. protected $_eventObject = 'shipment';
  57. /**
  58. * @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Item\CollectionFactory
  59. */
  60. protected $_shipmentItemCollectionFactory;
  61. /**
  62. * @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory
  63. */
  64. protected $_trackCollectionFactory;
  65. /**
  66. * @var \Magento\Sales\Model\Order\Shipment\CommentFactory
  67. */
  68. protected $_commentFactory;
  69. /**
  70. * @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment\CollectionFactory
  71. */
  72. protected $_commentCollectionFactory;
  73. /**
  74. * @var \Magento\Sales\Api\OrderRepositoryInterface
  75. */
  76. protected $orderRepository;
  77. /**
  78. * @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection
  79. */
  80. private $tracksCollection;
  81. /**
  82. * @var CommentsCollection
  83. */
  84. private $commentsCollection;
  85. /**
  86. * @param \Magento\Framework\Model\Context $context
  87. * @param \Magento\Framework\Registry $registry
  88. * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  89. * @param AttributeValueFactory $customAttributeFactory
  90. * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory
  91. * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory $trackCollectionFactory
  92. * @param Shipment\CommentFactory $commentFactory
  93. * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory
  94. * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
  95. * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  96. * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  97. * @param array $data
  98. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  99. */
  100. public function __construct(
  101. \Magento\Framework\Model\Context $context,
  102. \Magento\Framework\Registry $registry,
  103. \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
  104. AttributeValueFactory $customAttributeFactory,
  105. \Magento\Sales\Model\ResourceModel\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory,
  106. \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory $trackCollectionFactory,
  107. \Magento\Sales\Model\Order\Shipment\CommentFactory $commentFactory,
  108. \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory,
  109. \Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
  110. \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
  111. \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
  112. array $data = []
  113. ) {
  114. $this->_shipmentItemCollectionFactory = $shipmentItemCollectionFactory;
  115. $this->_trackCollectionFactory = $trackCollectionFactory;
  116. $this->_commentFactory = $commentFactory;
  117. $this->_commentCollectionFactory = $commentCollectionFactory;
  118. $this->orderRepository = $orderRepository;
  119. parent::__construct(
  120. $context,
  121. $registry,
  122. $extensionFactory,
  123. $customAttributeFactory,
  124. $resource,
  125. $resourceCollection,
  126. $data
  127. );
  128. }
  129. /**
  130. * Initialize shipment resource model
  131. *
  132. * @return void
  133. */
  134. protected function _construct()
  135. {
  136. $this->_init(\Magento\Sales\Model\ResourceModel\Order\Shipment::class);
  137. }
  138. /**
  139. * Load shipment by increment id
  140. *
  141. * @param string $incrementId
  142. * @return $this
  143. */
  144. public function loadByIncrementId($incrementId)
  145. {
  146. $ids = $this->getCollection()->addAttributeToFilter('increment_id', $incrementId)->getAllIds();
  147. if (!empty($ids)) {
  148. reset($ids);
  149. $this->load(current($ids));
  150. }
  151. return $this;
  152. }
  153. /**
  154. * Declare order for shipment
  155. *
  156. * @param \Magento\Sales\Model\Order $order
  157. * @return $this
  158. */
  159. public function setOrder(\Magento\Sales\Model\Order $order)
  160. {
  161. $this->_order = $order;
  162. $this->setOrderId($order->getId())->setStoreId($order->getStoreId());
  163. return $this;
  164. }
  165. /**
  166. * Retrieve hash code of current order
  167. *
  168. * @return string
  169. */
  170. public function getProtectCode()
  171. {
  172. return (string)$this->getOrder()->getProtectCode();
  173. }
  174. /**
  175. * Retrieve the order the shipment for created for
  176. *
  177. * @return \Magento\Sales\Model\Order
  178. */
  179. public function getOrder()
  180. {
  181. if (!$this->_order instanceof \Magento\Sales\Model\Order) {
  182. $this->_order = $this->orderRepository->get($this->getOrderId());
  183. }
  184. return $this->_order->setHistoryEntityName($this->entityType);
  185. }
  186. /**
  187. * Return order history item identifier
  188. *
  189. * @codeCoverageIgnore
  190. *
  191. * @return string
  192. */
  193. public function getEntityType()
  194. {
  195. return $this->entityType;
  196. }
  197. /**
  198. * Retrieve billing address
  199. *
  200. * @return Address
  201. */
  202. public function getBillingAddress()
  203. {
  204. return $this->getOrder()->getBillingAddress();
  205. }
  206. /**
  207. * Retrieve shipping address
  208. *
  209. * @return Address
  210. */
  211. public function getShippingAddress()
  212. {
  213. return $this->getOrder()->getShippingAddress();
  214. }
  215. /**
  216. * Registers shipment.
  217. *
  218. * @return $this
  219. * @throws \Magento\Framework\Exception\LocalizedException
  220. */
  221. public function register()
  222. {
  223. if ($this->getId()) {
  224. throw new \Magento\Framework\Exception\LocalizedException(
  225. __('We cannot register an existing shipment')
  226. );
  227. }
  228. $totalQty = 0;
  229. /** @var \Magento\Sales\Model\Order\Shipment\Item $item */
  230. foreach ($this->getAllItems() as $item) {
  231. if ($item->getQty() > 0) {
  232. $item->register();
  233. if (!$item->getOrderItem()->isDummy(true)) {
  234. $totalQty += $item->getQty();
  235. }
  236. }
  237. }
  238. $this->setTotalQty($totalQty);
  239. return $this;
  240. }
  241. /**
  242. * Retrieves the collection used to track the shipment's items
  243. *
  244. * @return mixed
  245. */
  246. public function getItemsCollection()
  247. {
  248. if (!$this->hasData(ShipmentInterface::ITEMS)) {
  249. $this->setItems($this->_shipmentItemCollectionFactory->create()->setShipmentFilter($this->getId()));
  250. if ($this->getId()) {
  251. foreach ($this->getItems() as $item) {
  252. $item->setShipment($this);
  253. }
  254. }
  255. }
  256. return $this->getItems();
  257. }
  258. /**
  259. * Retrieves all non-deleted items from the shipment
  260. *
  261. * @return array
  262. */
  263. public function getAllItems()
  264. {
  265. $items = [];
  266. foreach ($this->getItemsCollection() as $item) {
  267. if (!$item->isDeleted()) {
  268. $items[] = $item;
  269. }
  270. }
  271. return $items;
  272. }
  273. /**
  274. * Retrieves an item from the shipment using its ID
  275. *
  276. * @param string|int $itemId
  277. * @return bool|\Magento\Sales\Model\Order\Shipment\Item
  278. */
  279. public function getItemById($itemId)
  280. {
  281. foreach ($this->getItemsCollection() as $item) {
  282. if ($item->getId() == $itemId) {
  283. return $item;
  284. }
  285. }
  286. return false;
  287. }
  288. /**
  289. * Adds an item to the shipment
  290. *
  291. * @param \Magento\Sales\Model\Order\Shipment\Item $item
  292. * @return $this
  293. */
  294. public function addItem(\Magento\Sales\Model\Order\Shipment\Item $item)
  295. {
  296. $item->setShipment($this)->setParentId($this->getId())->setStoreId($this->getStoreId());
  297. if (!$item->getId()) {
  298. $this->setItems(array_merge(
  299. $this->getItems() ?? [],
  300. [$item]
  301. ));
  302. }
  303. return $this;
  304. }
  305. /**
  306. * Retrieve tracks collection.
  307. *
  308. * @return \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection
  309. */
  310. public function getTracksCollection()
  311. {
  312. if ($this->tracksCollection === null) {
  313. $this->tracksCollection = $this->_trackCollectionFactory->create();
  314. $id = $this->getId() ?: 0;
  315. $this->tracksCollection->setShipmentFilter($id);
  316. foreach ($this->tracksCollection as $item) {
  317. $item->setShipment($this);
  318. }
  319. }
  320. return $this->tracksCollection;
  321. }
  322. /**
  323. * Retrieves all available tracks in the collection that aren't deleted
  324. *
  325. * @return array
  326. */
  327. public function getAllTracks()
  328. {
  329. $tracks = [];
  330. foreach ($this->getTracksCollection() as $track) {
  331. if (!$track->isDeleted()) {
  332. $tracks[] = $track;
  333. }
  334. }
  335. return $tracks;
  336. }
  337. /**
  338. * Retrieves a track using its ID
  339. *
  340. * @param string|int $trackId
  341. * @return bool|\Magento\Sales\Model\Order\Shipment\Track
  342. */
  343. public function getTrackById($trackId)
  344. {
  345. foreach ($this->getTracksCollection() as $track) {
  346. if ($track->getId() == $trackId) {
  347. return $track;
  348. }
  349. }
  350. return false;
  351. }
  352. /**
  353. * Addes a track to the collection and associates the shipment to the track
  354. *
  355. * @param \Magento\Sales\Model\Order\Shipment\Track $track
  356. * @return $this
  357. */
  358. public function addTrack(\Magento\Sales\Model\Order\Shipment\Track $track)
  359. {
  360. $track->setShipment($this)
  361. ->setParentId($this->getId())
  362. ->setOrderId($this->getOrderId())
  363. ->setStoreId($this->getStoreId());
  364. if (!$track->getId()) {
  365. $this->getTracksCollection()->addItem($track);
  366. }
  367. $tracks = $this->getTracks();
  368. // as it's a new track entity, the collection doesn't contain it
  369. $tracks[] = $track;
  370. $this->setTracks($tracks);
  371. /**
  372. * Track saving is implemented in _afterSave()
  373. * This enforces \Magento\Framework\Model\AbstractModel::save() not to skip _afterSave()
  374. */
  375. $this->_hasDataChanges = true;
  376. return $this;
  377. }
  378. /**
  379. * Adds comment to shipment with option to send it to customer via email and show it in customer account
  380. *
  381. * @param \Magento\Sales\Model\Order\Shipment\Comment|string $comment
  382. * @param bool $notify
  383. * @param bool $visibleOnFront
  384. * @return $this
  385. */
  386. public function addComment($comment, $notify = false, $visibleOnFront = false)
  387. {
  388. if (!$comment instanceof \Magento\Sales\Model\Order\Shipment\Comment) {
  389. $comment = $this->_commentFactory->create()
  390. ->setComment($comment)
  391. ->setIsCustomerNotified($notify)
  392. ->setIsVisibleOnFront($visibleOnFront);
  393. }
  394. $comment->setShipment($this)
  395. ->setParentId($this->getId())
  396. ->setStoreId($this->getStoreId());
  397. if (!$comment->getId()) {
  398. $this->getCommentsCollection()->addItem($comment);
  399. }
  400. $comments = $this->getComments();
  401. $comments[] = $comment;
  402. $this->setComments($comments);
  403. $this->_hasDataChanges = true;
  404. return $this;
  405. }
  406. /**
  407. * Retrieves comments collection.
  408. *
  409. * @param bool $reload
  410. * @return CommentsCollection
  411. */
  412. public function getCommentsCollection($reload = false)
  413. {
  414. if ($this->commentsCollection === null || $reload) {
  415. $this->commentsCollection = $this->_commentCollectionFactory->create();
  416. if ($this->getId()) {
  417. $this->commentsCollection->setShipmentFilter($this->getId())
  418. ->setCreatedAtOrder();
  419. foreach ($this->commentsCollection as $comment) {
  420. $comment->setShipment($this);
  421. }
  422. }
  423. }
  424. return $this->commentsCollection;
  425. }
  426. /**
  427. * Retrieve store model instance
  428. *
  429. * @return \Magento\Store\Model\Store
  430. */
  431. public function getStore()
  432. {
  433. return $this->getOrder()->getStore();
  434. }
  435. /**
  436. * Set shipping label
  437. *
  438. * @param string $label label representation (image or pdf file)
  439. * @return $this
  440. */
  441. public function setShippingLabel($label)
  442. {
  443. $this->setData('shipping_label', $label);
  444. return $this;
  445. }
  446. /**
  447. * Get shipping label and decode by db adapter
  448. *
  449. * @return mixed
  450. */
  451. public function getShippingLabel()
  452. {
  453. $label = $this->getData('shipping_label');
  454. if ($label) {
  455. return $this->getResource()->getConnection()->decodeVarbinary($label);
  456. }
  457. return $label;
  458. }
  459. /**
  460. * Returns increment id
  461. *
  462. * @codeCoverageIgnore
  463. *
  464. * @return string
  465. */
  466. public function getIncrementId()
  467. {
  468. return $this->getData('increment_id');
  469. }
  470. /**
  471. * Returns packages
  472. *
  473. * @codeCoverageIgnore
  474. *
  475. * @return string
  476. */
  477. public function getPackages()
  478. {
  479. return $this->getData(ShipmentInterface::PACKAGES);
  480. }
  481. /**
  482. * @inheritdoc
  483. * @codeCoverageIgnore
  484. */
  485. public function setPackages(array $packages = null)
  486. {
  487. return $this->setData(ShipmentInterface::PACKAGES, $packages);
  488. }
  489. /**
  490. * Returns items
  491. *
  492. * @return \Magento\Sales\Api\Data\ShipmentItemInterface[]
  493. */
  494. public function getItems()
  495. {
  496. if ($this->getData(ShipmentInterface::ITEMS) === null) {
  497. $collection = $this->_shipmentItemCollectionFactory->create()->setShipmentFilter($this->getId());
  498. if ($this->getId()) {
  499. foreach ($collection as $item) {
  500. $item->setShipment($this);
  501. }
  502. $this->setData(ShipmentInterface::ITEMS, $collection->getItems());
  503. }
  504. }
  505. $shipmentItems = $this->getData(ShipmentInterface::ITEMS);
  506. if ($shipmentItems !== null && !is_array($shipmentItems)) {
  507. $shipmentItems = $shipmentItems->getItems();
  508. }
  509. return $shipmentItems;
  510. }
  511. /**
  512. * Sets items
  513. *
  514. * @codeCoverageIgnore
  515. *
  516. * @param mixed $items
  517. * @return $this
  518. */
  519. public function setItems($items)
  520. {
  521. return $this->setData(ShipmentInterface::ITEMS, $items);
  522. }
  523. /**
  524. * Returns tracks
  525. *
  526. * @return \Magento\Sales\Api\Data\ShipmentTrackInterface[]|null
  527. */
  528. public function getTracks()
  529. {
  530. if (!$this->getId()) {
  531. return $this->getData(ShipmentInterface::TRACKS);
  532. }
  533. if ($this->getData(ShipmentInterface::TRACKS) === null) {
  534. $this->setData(ShipmentInterface::TRACKS, $this->getTracksCollection()->getItems());
  535. }
  536. return $this->getData(ShipmentInterface::TRACKS);
  537. }
  538. //@codeCoverageIgnoreStart
  539. /**
  540. * Returns tracks
  541. *
  542. * @param \Magento\Sales\Api\Data\ShipmentTrackInterface[] $tracks
  543. * @return $this
  544. */
  545. public function setTracks($tracks)
  546. {
  547. return $this->setData(ShipmentInterface::TRACKS, $tracks);
  548. }
  549. /**
  550. * Returns billing_address_id
  551. *
  552. * @return int
  553. */
  554. public function getBillingAddressId()
  555. {
  556. return $this->getData(ShipmentInterface::BILLING_ADDRESS_ID);
  557. }
  558. /**
  559. * Returns created_at
  560. *
  561. * @return string
  562. */
  563. public function getCreatedAt()
  564. {
  565. return $this->getData(ShipmentInterface::CREATED_AT);
  566. }
  567. /**
  568. * @inheritdoc
  569. */
  570. public function setCreatedAt($createdAt)
  571. {
  572. return $this->setData(ShipmentInterface::CREATED_AT, $createdAt);
  573. }
  574. /**
  575. * Returns customer_id
  576. *
  577. * @return int
  578. */
  579. public function getCustomerId()
  580. {
  581. return $this->getData(ShipmentInterface::CUSTOMER_ID);
  582. }
  583. /**
  584. * Returns email_sent
  585. *
  586. * @return int
  587. */
  588. public function getEmailSent()
  589. {
  590. return $this->getData(ShipmentInterface::EMAIL_SENT);
  591. }
  592. /**
  593. * Returns order_id
  594. *
  595. * @return int
  596. */
  597. public function getOrderId()
  598. {
  599. return $this->getData(ShipmentInterface::ORDER_ID);
  600. }
  601. /**
  602. * Returns shipment_status
  603. *
  604. * @return int
  605. */
  606. public function getShipmentStatus()
  607. {
  608. return $this->getData(ShipmentInterface::SHIPMENT_STATUS);
  609. }
  610. /**
  611. * Returns shipping_address_id
  612. *
  613. * @return int
  614. */
  615. public function getShippingAddressId()
  616. {
  617. return $this->getData(ShipmentInterface::SHIPPING_ADDRESS_ID);
  618. }
  619. /**
  620. * Returns store_id
  621. *
  622. * @return int
  623. */
  624. public function getStoreId()
  625. {
  626. return $this->getData(ShipmentInterface::STORE_ID);
  627. }
  628. /**
  629. * Returns total_qty
  630. *
  631. * @return float
  632. */
  633. public function getTotalQty()
  634. {
  635. return $this->getData(ShipmentInterface::TOTAL_QTY);
  636. }
  637. /**
  638. * Returns total_weight
  639. *
  640. * @return float
  641. */
  642. public function getTotalWeight()
  643. {
  644. return $this->getData(ShipmentInterface::TOTAL_WEIGHT);
  645. }
  646. /**
  647. * Returns updated_at
  648. *
  649. * @return string
  650. */
  651. public function getUpdatedAt()
  652. {
  653. return $this->getData(ShipmentInterface::UPDATED_AT);
  654. }
  655. /**
  656. * Returns comments
  657. *
  658. * @return \Magento\Sales\Api\Data\ShipmentCommentInterface[]
  659. */
  660. public function getComments()
  661. {
  662. if (!$this->getId()) {
  663. return $this->getData(ShipmentInterface::COMMENTS);
  664. }
  665. if ($this->getData(ShipmentInterface::COMMENTS) == null) {
  666. $collection = $this->_commentCollectionFactory->create()
  667. ->setShipmentFilter($this->getId());
  668. foreach ($collection as $item) {
  669. $item->setShipment($this);
  670. }
  671. $this->setData(ShipmentInterface::COMMENTS, $collection->getItems());
  672. }
  673. return $this->getData(ShipmentInterface::COMMENTS);
  674. }
  675. /**
  676. * Sets comments
  677. *
  678. * @param \Magento\Sales\Api\Data\ShipmentCommentInterface[] $comments
  679. * @return $this
  680. */
  681. public function setComments($comments = null)
  682. {
  683. return $this->setData(ShipmentInterface::COMMENTS, $comments);
  684. }
  685. /**
  686. * @inheritdoc
  687. */
  688. public function setStoreId($id)
  689. {
  690. return $this->setData(ShipmentInterface::STORE_ID, $id);
  691. }
  692. /**
  693. * @inheritdoc
  694. */
  695. public function setTotalWeight($totalWeight)
  696. {
  697. return $this->setData(ShipmentInterface::TOTAL_WEIGHT, $totalWeight);
  698. }
  699. /**
  700. * @inheritdoc
  701. */
  702. public function setTotalQty($qty)
  703. {
  704. return $this->setData(ShipmentInterface::TOTAL_QTY, $qty);
  705. }
  706. /**
  707. * @inheritdoc
  708. */
  709. public function setEmailSent($emailSent)
  710. {
  711. return $this->setData(ShipmentInterface::EMAIL_SENT, $emailSent);
  712. }
  713. /**
  714. * @inheritdoc
  715. */
  716. public function setOrderId($id)
  717. {
  718. return $this->setData(ShipmentInterface::ORDER_ID, $id);
  719. }
  720. /**
  721. * @inheritdoc
  722. */
  723. public function setCustomerId($id)
  724. {
  725. return $this->setData(ShipmentInterface::CUSTOMER_ID, $id);
  726. }
  727. /**
  728. * @inheritdoc
  729. */
  730. public function setShippingAddressId($id)
  731. {
  732. return $this->setData(ShipmentInterface::SHIPPING_ADDRESS_ID, $id);
  733. }
  734. /**
  735. * @inheritdoc
  736. */
  737. public function setBillingAddressId($id)
  738. {
  739. return $this->setData(ShipmentInterface::BILLING_ADDRESS_ID, $id);
  740. }
  741. /**
  742. * @inheritdoc
  743. */
  744. public function setShipmentStatus($shipmentStatus)
  745. {
  746. return $this->setData(ShipmentInterface::SHIPMENT_STATUS, $shipmentStatus);
  747. }
  748. /**
  749. * @inheritdoc
  750. */
  751. public function setIncrementId($id)
  752. {
  753. return $this->setData(ShipmentInterface::INCREMENT_ID, $id);
  754. }
  755. /**
  756. * @inheritdoc
  757. */
  758. public function setUpdatedAt($timestamp)
  759. {
  760. return $this->setData(ShipmentInterface::UPDATED_AT, $timestamp);
  761. }
  762. /**
  763. * @inheritdoc
  764. *
  765. * @return \Magento\Sales\Api\Data\ShipmentExtensionInterface|null
  766. */
  767. public function getExtensionAttributes()
  768. {
  769. return $this->_getExtensionAttributes();
  770. }
  771. /**
  772. * @inheritdoc
  773. *
  774. * @param \Magento\Sales\Api\Data\ShipmentExtensionInterface $extensionAttributes
  775. * @return $this
  776. */
  777. public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentExtensionInterface $extensionAttributes)
  778. {
  779. return $this->_setExtensionAttributes($extensionAttributes);
  780. }
  781. //@codeCoverageIgnoreEnd
  782. }