66
77namespace Magento \CatalogRule \Cron ;
88
9- use Magento \CatalogRule \Model \Indexer \PartialIndex ;
109use Magento \CatalogRule \Model \Indexer \Rule \RuleProductProcessor ;
10+ use Magento \CatalogRule \Model \ResourceModel \Rule \CollectionFactory as RuleCollectionFactory ;
1111
1212/**
1313 * Daily update catalog price rule by cron
@@ -20,24 +20,25 @@ class DailyCatalogUpdate
2020 protected $ ruleProductProcessor ;
2121
2222 /**
23- * @var PartialIndex
23+ * @var RuleCollectionFactory
2424 */
25- private $ partialIndex ;
25+ private $ ruleCollectionFactory ;
2626
2727 /**
2828 * @param RuleProductProcessor $ruleProductProcessor
29- * @param PartialIndex $partialIndex
29+ * @param RuleCollectionFactory $ruleCollectionFactory
3030 */
3131 public function __construct (
3232 RuleProductProcessor $ ruleProductProcessor ,
33- PartialIndex $ partialIndex
33+ RuleCollectionFactory $ ruleCollectionFactory
3434 ) {
3535 $ this ->ruleProductProcessor = $ ruleProductProcessor ;
36- $ this ->partialIndex = $ partialIndex ;
36+ $ this ->ruleCollectionFactory = $ ruleCollectionFactory ;
3737 }
3838
3939 /**
4040 * Daily update catalog price rule by cron
41+ *
4142 * Update include interval 3 days - current day - 1 days before + 1 days after
4243 * This method is called from cron process, cron is working in UTC time and
4344 * we should generate data for interval -1 day ... +1 day
@@ -46,8 +47,10 @@ public function __construct(
4647 */
4748 public function execute ()
4849 {
49- $ this ->ruleProductProcessor ->isIndexerScheduled ()
50- ? $ this ->partialIndex ->partialUpdateCatalogRuleProductPrice ()
51- : $ this ->ruleProductProcessor ->markIndexerAsInvalid ();
50+ $ ruleCollection = $ this ->ruleCollectionFactory ->create ();
51+ $ ruleCollection ->addIsActiveFilter ();
52+ if ($ ruleCollection ->getSize ()) {
53+ $ this ->ruleProductProcessor ->markIndexerAsInvalid ();
54+ }
5255 }
5356}
0 commit comments