SynchronizeWebsiteAttributes.php 938 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Catalog\Cron;
  7. use Magento\Catalog\Model\ResourceModel\Attribute\WebsiteAttributesSynchronizer;
  8. /**
  9. * Class SynchronizeWebsiteAttributes
  10. * @package Magento\Catalog\Cron
  11. */
  12. class SynchronizeWebsiteAttributes
  13. {
  14. /**
  15. * @var WebsiteAttributesSynchronizer
  16. */
  17. private $synchronizer;
  18. /**
  19. * SynchronizeWebsiteAttributes constructor.
  20. * @param WebsiteAttributesSynchronizer $synchronizer
  21. */
  22. public function __construct(WebsiteAttributesSynchronizer $synchronizer)
  23. {
  24. $this->synchronizer = $synchronizer;
  25. }
  26. /**
  27. * Synchronizes website attribute values if needed
  28. * @return void
  29. */
  30. public function execute()
  31. {
  32. if ($this->synchronizer->isSynchronizationRequired()) {
  33. $this->synchronizer->synchronize();
  34. }
  35. }
  36. }