StoreWebsiteRelation.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Store\Model\ResourceModel;
  7. use Magento\Framework\App\ResourceConnection;
  8. /**
  9. * Store Website Relation Resource Model
  10. */
  11. class StoreWebsiteRelation
  12. {
  13. /**
  14. * @var \Magento\Framework\App\ResourceConnection
  15. */
  16. private $resource;
  17. /**
  18. * StoreWebsiteRelation constructor.
  19. * @param ResourceConnection $resource
  20. */
  21. public function __construct(ResourceConnection $resource)
  22. {
  23. $this->resource = $resource;
  24. }
  25. /**
  26. * @param int $websiteId
  27. * @return array
  28. */
  29. public function getStoreByWebsiteId($websiteId)
  30. {
  31. $connection = $this->resource->getConnection();
  32. $storeTable = $this->resource->getTableName('store');
  33. $storeSelect = $connection->select()->from($storeTable, ['store_id'])->where(
  34. 'website_id = ?',
  35. $websiteId
  36. );
  37. $data = $connection->fetchCol($storeSelect);
  38. return $data;
  39. }
  40. }