ShipmentReferenceCollection.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Model\ResourceModel\Shipment;
  6. use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
  7. use Temando\Shipping\Model\ResourceModel\Shipment\ShipmentReference as ShipmentReferenceResource;
  8. use Temando\Shipping\Model\Shipment\ShipmentReference;
  9. /**
  10. * Temando Shipment Reference Resource Collection
  11. *
  12. * @package Temando\Shipping\Model
  13. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  14. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  15. * @link http://www.temando.com/
  16. */
  17. class ShipmentReferenceCollection extends AbstractCollection
  18. {
  19. /**
  20. * Event prefix
  21. *
  22. * @var string
  23. */
  24. protected $_eventPrefix = 'temando_shipment_reference_collection';
  25. /**
  26. * Event object name
  27. *
  28. * @var string
  29. */
  30. protected $_eventObject = 'shipment_reference_collection';
  31. /**
  32. * Init collection and determine table names
  33. *
  34. * @return void
  35. */
  36. protected function _construct()
  37. {
  38. $this->_init(ShipmentReference::class, ShipmentReferenceResource::class);
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. protected function _initSelect()
  44. {
  45. parent::_initSelect();
  46. $salesShipmentTable = $this->getTable('sales_shipment');
  47. $salesOrderTable = $this->getTable('sales_order');
  48. $this->getSelect()
  49. ->join(['s' => $salesShipmentTable], 's.entity_id = main_table.shipment_id', [])
  50. ->join(['o' => $salesOrderTable], 'o.entity_id = s.order_id', []);
  51. return $this;
  52. }
  53. }