QuoteConfigProductAttributes.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\SalesRule\Model\Plugin;
  7. use Magento\SalesRule\Model\ResourceModel\Rule as RuleResource;
  8. /**
  9. * Quote Config Product Attributes Class
  10. */
  11. class QuoteConfigProductAttributes
  12. {
  13. /**
  14. * @var RuleResource
  15. */
  16. protected $_ruleResource;
  17. /**
  18. * @param RuleResource $ruleResource
  19. */
  20. public function __construct(RuleResource $ruleResource)
  21. {
  22. $this->_ruleResource = $ruleResource;
  23. }
  24. /**
  25. * Append sales rule product attribute keys to select by quote item collection
  26. *
  27. * @param \Magento\Quote\Model\Quote\Config $subject
  28. * @param array $attributeKeys
  29. *
  30. * @return array
  31. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  32. */
  33. public function afterGetProductAttributes(\Magento\Quote\Model\Quote\Config $subject, array $attributeKeys)
  34. {
  35. $attributes = $this->_ruleResource->getActiveAttributes();
  36. foreach ($attributes as $attribute) {
  37. $attributeKeys[] = $attribute['attribute_code'];
  38. }
  39. return $attributeKeys;
  40. }
  41. }