SynonymGroup.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Search\Model\ResourceModel;
  7. use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
  8. /**
  9. * @api
  10. * @since 100.1.0
  11. */
  12. class SynonymGroup extends AbstractDb
  13. {
  14. /**
  15. * Get synonym groups by scope
  16. *
  17. * @param int $websiteId
  18. * @param int $storeId
  19. * @return string[]
  20. * @since 100.1.0
  21. */
  22. public function getByScope($websiteId, $storeId)
  23. {
  24. $websiteIdField = $this->getConnection()
  25. ->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), 'website_id'));
  26. $storeIdField = $this->getConnection()
  27. ->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), 'store_id'));
  28. $select = $this->getConnection()
  29. ->select()
  30. ->from($this->getMainTable(), ['group_id', 'synonyms'])
  31. ->where($websiteIdField . '=?', $websiteId)
  32. ->where($storeIdField . '=?', $storeId);
  33. return $this->getConnection()->fetchAll($select);
  34. }
  35. /**
  36. * Init resource data
  37. *
  38. * @return void
  39. * @since 100.1.0
  40. */
  41. protected function _construct()
  42. {
  43. $this->_init('search_synonyms', 'group_id');
  44. }
  45. }