46
46
* @SuppressWarnings(PHPMD.TooManyFields)
47
47
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
48
48
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
49
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
49
50
*/
50
51
class Rule extends \Magento \Rule \Model \AbstractModel implements RuleInterface, IdentityInterface
51
52
{
@@ -433,7 +434,7 @@ protected function _getWebsitesMap()
433
434
}
434
435
435
436
/**
436
- * { @inheritdoc}
437
+ * @inheritdoc
437
438
*/
438
439
public function validateData (DataObject $ dataObject )
439
440
{
@@ -582,12 +583,16 @@ protected function _invalidateCache()
582
583
}
583
584
584
585
/**
585
- * { @inheritdoc}
586
+ * @inheritdoc
586
587
*
587
588
* @return $this
588
589
*/
589
590
public function afterSave ()
590
591
{
592
+ if (!$ this ->getIsActive ()) {
593
+ return parent ::afterSave ();
594
+ }
595
+
591
596
if ($ this ->isObjectNew () && !$ this ->_ruleProductProcessor ->isIndexerScheduled ()) {
592
597
$ productIds = $ this ->getMatchingProductIds ();
593
598
if (!empty ($ productIds ) && is_array ($ productIds )) {
@@ -606,14 +611,19 @@ public function afterSave()
606
611
*/
607
612
public function reindex ()
608
613
{
609
- $ productIds = $ this ->_productIds ? array_keys (array_filter ($ this ->_productIds , function (array $ data ) {
610
- return array_filter ($ data );
611
- })) : [];
614
+ $ productIds = $ this ->_productIds ? array_keys (
615
+ array_filter (
616
+ $ this ->_productIds ,
617
+ function (array $ data ) {
618
+ return array_filter ($ data );
619
+ }
620
+ )
621
+ ) : [];
612
622
$ this ->_ruleProductProcessor ->reindexList ($ productIds );
613
623
}
614
624
615
625
/**
616
- * { @inheritdoc}
626
+ * @inheritdoc
617
627
*
618
628
* @return $this
619
629
*/
@@ -643,6 +653,7 @@ public function isRuleBehaviorChanged()
643
653
644
654
/**
645
655
* Get array with data differences
656
+ *
646
657
* @param array $array1
647
658
* @param array $array2
648
659
*
@@ -664,6 +675,8 @@ protected function dataDiff($array1, $array2)
664
675
}
665
676
666
677
/**
678
+ * Getter for conditions field set ID
679
+ *
667
680
* @param string $formName
668
681
* @return string
669
682
*/
@@ -672,82 +685,80 @@ public function getConditionsFieldSetId($formName = '')
672
685
return $ formName . 'rule_conditions_fieldset_ ' . $ this ->getId ();
673
686
}
674
687
675
- //@codeCoverageIgnoreStart
676
-
677
688
/**
678
- * { @inheritdoc}
689
+ * @inheritdoc
679
690
*/
680
691
public function getRuleId ()
681
692
{
682
693
return $ this ->getData (self ::RULE_ID );
683
694
}
684
695
685
696
/**
686
- * { @inheritdoc}
697
+ * @inheritdoc
687
698
*/
688
699
public function setRuleId ($ ruleId )
689
700
{
690
701
return $ this ->setData (self ::RULE_ID , $ ruleId );
691
702
}
692
703
693
704
/**
694
- * { @inheritdoc}
705
+ * @inheritdoc
695
706
*/
696
707
public function getName ()
697
708
{
698
709
return $ this ->getData (self ::NAME );
699
710
}
700
711
701
712
/**
702
- * { @inheritdoc}
713
+ * @inheritdoc
703
714
*/
704
715
public function setName ($ name )
705
716
{
706
717
return $ this ->setData (self ::NAME , $ name );
707
718
}
708
719
709
720
/**
710
- * { @inheritdoc}
721
+ * @inheritdoc
711
722
*/
712
723
public function getDescription ()
713
724
{
714
725
return $ this ->getData (self ::DESCRIPTION );
715
726
}
716
727
717
728
/**
718
- * { @inheritdoc}
729
+ * @inheritdoc
719
730
*/
720
731
public function setDescription ($ description )
721
732
{
722
733
return $ this ->setData (self ::DESCRIPTION , $ description );
723
734
}
724
735
725
736
/**
726
- * { @inheritdoc}
737
+ * @inheritdoc
727
738
*/
728
739
public function getIsActive ()
729
740
{
730
741
return $ this ->getData (self ::IS_ACTIVE );
731
742
}
732
743
733
744
/**
734
- * { @inheritdoc}
745
+ * @inheritdoc
735
746
*/
736
747
public function setIsActive ($ isActive )
737
748
{
738
749
return $ this ->setData (self ::IS_ACTIVE , $ isActive );
739
750
}
740
751
741
752
/**
742
- * { @inheritdoc}
753
+ * @inheritdoc
743
754
*/
744
755
public function getRuleCondition ()
745
756
{
746
757
return $ this ->getRuleConditionConverter ()->arrayToDataModel ($ this ->getConditions ()->asArray ());
747
758
}
748
759
749
760
/**
750
- * { @inheritdoc}
761
+ * @inheritdoc
751
762
*/
752
763
public function setRuleCondition ($ condition )
753
764
{
@@ -758,70 +769,72 @@ public function setRuleCondition($condition)
758
769
}
759
770
760
771
/**
761
- * { @inheritdoc}
772
+ * @inheritdoc
762
773
*/
763
774
public function getStopRulesProcessing ()
764
775
{
765
776
return $ this ->getData (self ::STOP_RULES_PROCESSING );
766
777
}
767
778
768
779
/**
769
- * { @inheritdoc}
780
+ * @inheritdoc
770
781
*/
771
782
public function setStopRulesProcessing ($ isStopProcessing )
772
783
{
773
784
return $ this ->setData (self ::STOP_RULES_PROCESSING , $ isStopProcessing );
774
785
}
775
786
776
787
/**
777
- * { @inheritdoc}
788
+ * @inheritdoc
778
789
*/
779
790
public function getSortOrder ()
780
791
{
781
792
return $ this ->getData (self ::SORT_ORDER );
782
793
}
783
794
784
795
/**
785
- * { @inheritdoc}
796
+ * @inheritdoc
786
797
*/
787
798
public function setSortOrder ($ sortOrder )
788
799
{
789
800
return $ this ->setData (self ::SORT_ORDER , $ sortOrder );
790
801
}
791
802
792
803
/**
793
- * { @inheritdoc}
804
+ * @inheritdoc
794
805
*/
795
806
public function getSimpleAction ()
796
807
{
797
808
return $ this ->getData (self ::SIMPLE_ACTION );
798
809
}
799
810
800
811
/**
801
- * { @inheritdoc}
812
+ * @inheritdoc
802
813
*/
803
814
public function setSimpleAction ($ action )
804
815
{
805
816
return $ this ->setData (self ::SIMPLE_ACTION , $ action );
806
817
}
807
818
808
819
/**
809
- * { @inheritdoc}
820
+ * @inheritdoc
810
821
*/
811
822
public function getDiscountAmount ()
812
823
{
813
824
return $ this ->getData (self ::DISCOUNT_AMOUNT );
814
825
}
815
826
816
827
/**
817
- * { @inheritdoc}
828
+ * @inheritdoc
818
829
*/
819
830
public function setDiscountAmount ($ amount )
820
831
{
821
832
return $ this ->setData (self ::DISCOUNT_AMOUNT , $ amount );
822
833
}
823
834
824
835
/**
836
+ * Get from date
837
+ *
825
838
* @return string
826
839
*/
827
840
public function getFromDate ()
@@ -830,6 +843,8 @@ public function getFromDate()
830
843
}
831
844
832
845
/**
846
+ * Get to date
847
+ *
833
848
* @return string
834
849
*/
835
850
public function getToDate ()
@@ -838,7 +853,7 @@ public function getToDate()
838
853
}
839
854
840
855
/**
841
- * { @inheritdoc}
856
+ * @inheritdoc
842
857
*
843
858
* @return \Magento\CatalogRule\Api\Data\RuleExtensionInterface|null
844
859
*/
@@ -848,7 +863,7 @@ public function getExtensionAttributes()
848
863
}
849
864
850
865
/**
851
- * { @inheritdoc}
866
+ * @inheritdoc
852
867
*
853
868
* @param \Magento\CatalogRule\Api\Data\RuleExtensionInterface $extensionAttributes
854
869
* @return $this
@@ -859,6 +874,8 @@ public function setExtensionAttributes(RuleExtensionInterface $extensionAttribut
859
874
}
860
875
861
876
/**
877
+ * Getter for the rule condition converter
878
+ *
862
879
* @return Data\Condition\Converter
863
880
* @deprecated 100.1.0
864
881
*/
@@ -871,8 +888,6 @@ private function getRuleConditionConverter()
871
888
return $ this ->ruleConditionConverter ;
872
889
}
873
890
874
- //@codeCoverageIgnoreEnd
875
-
876
891
/**
877
892
* @inheritDoc
878
893
*/
0 commit comments