Collection.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Swatches\Model\ResourceModel\Swatch;
  7. /**
  8. * @codeCoverageIgnore
  9. * Swatch Resource Collection
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  14. {
  15. /**
  16. * Standard collection initialization
  17. *
  18. * @return void
  19. */
  20. protected function _construct()
  21. {
  22. $this->_init(\Magento\Swatches\Model\Swatch::class, \Magento\Swatches\Model\ResourceModel\Swatch::class);
  23. }
  24. /**
  25. * Adding store filter to collection
  26. *
  27. * @param int $storeId
  28. * @return $this
  29. */
  30. public function addStoreFilter($storeId)
  31. {
  32. $this->addFieldToFilter('main_table.store_id', ['eq' => $storeId]);
  33. return $this;
  34. }
  35. /**
  36. * Adding filter by Attribute options ids.
  37. *
  38. * @param array $optionsIds
  39. * @return $this
  40. */
  41. public function addFilterByOptionsIds(array $optionsIds)
  42. {
  43. $this->addFieldToFilter('main_table.option_id', ['in' => $optionsIds]);
  44. return $this;
  45. }
  46. }