CatalogProductAttributeSavePlugin.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Dotdigitalgroup\Email\Plugin;
  3. /**
  4. * Class CatalogProductAttributeSavePlugin - reset product in email_catalog when update attribute mass action is used.
  5. *
  6. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  7. */
  8. class CatalogProductAttributeSavePlugin
  9. {
  10. /**
  11. * @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute
  12. */
  13. private $attributeHelper;
  14. /**
  15. * @var \Dotdigitalgroup\Email\Model\ResourceModel\Catalog
  16. */
  17. private $catalogResource;
  18. public function __construct(
  19. \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper,
  20. \Dotdigitalgroup\Email\Model\ResourceModel\Catalog $catalogResource
  21. ) {
  22. $this->attributeHelper = $attributeHelper;
  23. $this->catalogResource = $catalogResource;
  24. }
  25. /**
  26. * @param \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save $subject
  27. * @param $result
  28. *
  29. * @return mixed
  30. */
  31. public function afterExecute(
  32. \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save $subject,
  33. $result
  34. ) {
  35. $productIds = $this->attributeHelper->getProductIds();
  36. if (! empty($productIds)) {
  37. $this->catalogResource->setModified($productIds);
  38. }
  39. return $result;
  40. }
  41. }