9
9
10
10
use Magento \Catalog \Model \Product ;
11
11
use Magento \CatalogRule \Model \ResourceModel \Rule ;
12
- use Magento \CatalogRule \Model \ResourceModel \RuleFactory ;
13
12
use Magento \Customer \Model \Session ;
14
- use Magento \Framework \App \ObjectManager ;
15
13
use Magento \Framework \Pricing \Adjustment \Calculator ;
16
14
use Magento \Framework \Pricing \Price \AbstractPrice ;
17
15
use Magento \Framework \Pricing \Price \BasePriceProviderInterface ;
16
+ use Magento \Framework \Pricing \PriceCurrencyInterface ;
18
17
use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
19
- use Magento \Store \Model \StoreManager ;
18
+ use Magento \Store \Model \StoreManagerInterface ;
20
19
21
20
/**
22
21
* Class CatalogRulePrice
@@ -31,56 +30,50 @@ class CatalogRulePrice extends AbstractPrice implements BasePriceProviderInterfa
31
30
const PRICE_CODE = 'catalog_rule_price ' ;
32
31
33
32
/**
34
- * @var \Magento\Framework\Stdlib\DateTime\ TimezoneInterface
33
+ * @var TimezoneInterface
35
34
*/
36
35
protected $ dateTime ;
37
36
38
37
/**
39
- * @var \Magento\Store\Model\StoreManager
38
+ * @var StoreManagerInterface
40
39
*/
41
40
protected $ storeManager ;
42
41
43
42
/**
44
- * @var \Magento\Customer\Model\ Session
43
+ * @var Session
45
44
*/
46
45
protected $ customerSession ;
47
46
48
47
/**
49
- * @var \Magento\CatalogRule\Model\ResourceModel\RuleFactory
50
- * @deprecated 100.1.1
51
- */
52
- protected $ resourceRuleFactory ;
53
-
54
- /**
55
- * @var \Magento\CatalogRule\Model\ResourceModel\Rule
48
+ * @var Rule
56
49
*/
57
50
private $ ruleResource ;
58
51
59
52
/**
60
53
* @param Product $saleableItem
61
54
* @param float $quantity
62
55
* @param Calculator $calculator
63
- * @param \Magento\Framework\Pricing\ PriceCurrencyInterface $priceCurrency
56
+ * @param PriceCurrencyInterface $priceCurrency
64
57
* @param TimezoneInterface $dateTime
65
- * @param StoreManager $storeManager
58
+ * @param StoreManagerInterface $storeManager
66
59
* @param Session $customerSession
67
- * @param RuleFactory $catalogRuleResourceFactory
60
+ * @param Rule $ruleResource
68
61
*/
69
62
public function __construct (
70
63
Product $ saleableItem ,
71
64
$ quantity ,
72
65
Calculator $ calculator ,
73
- \ Magento \ Framework \ Pricing \ PriceCurrencyInterface $ priceCurrency ,
66
+ PriceCurrencyInterface $ priceCurrency ,
74
67
TimezoneInterface $ dateTime ,
75
- StoreManager $ storeManager ,
68
+ StoreManagerInterface $ storeManager ,
76
69
Session $ customerSession ,
77
- RuleFactory $ catalogRuleResourceFactory
70
+ Rule $ ruleResource
78
71
) {
79
72
parent ::__construct ($ saleableItem , $ quantity , $ calculator , $ priceCurrency );
80
73
$ this ->dateTime = $ dateTime ;
81
74
$ this ->storeManager = $ storeManager ;
82
75
$ this ->customerSession = $ customerSession ;
83
- $ this ->resourceRuleFactory = $ catalogRuleResourceFactory ;
76
+ $ this ->ruleResource = $ ruleResource ;
84
77
}
85
78
86
79
/**
@@ -94,13 +87,12 @@ public function getValue()
94
87
if ($ this ->product ->hasData (self ::PRICE_CODE )) {
95
88
$ this ->value = (float )$ this ->product ->getData (self ::PRICE_CODE ) ?: false ;
96
89
} else {
97
- $ this ->value = $ this ->getRuleResource ()
98
- ->getRulePrice (
99
- $ this ->dateTime ->date (null , null , false ),
100
- $ this ->storeManager ->getStore ()->getWebsiteId (),
101
- $ this ->customerSession ->getCustomerGroupId (),
102
- $ this ->product ->getId ()
103
- );
90
+ $ this ->value = $ this ->ruleResource ->getRulePrice (
91
+ $ this ->dateTime ->date (null , null , false ),
92
+ $ this ->storeManager ->getStore ()->getWebsiteId (),
93
+ $ this ->customerSession ->getCustomerGroupId (),
94
+ $ this ->product ->getId ()
95
+ );
104
96
$ this ->value = $ this ->value ? (float )$ this ->value : false ;
105
97
}
106
98
if ($ this ->value ) {
@@ -110,19 +102,4 @@ public function getValue()
110
102
111
103
return $ this ->value ;
112
104
}
113
-
114
- /**
115
- * Retrieve rule resource
116
- *
117
- * @return Rule
118
- * @deprecated 100.1.1
119
- */
120
- private function getRuleResource ()
121
- {
122
- if (null === $ this ->ruleResource ) {
123
- $ this ->ruleResource = ObjectManager::getInstance ()->get (Rule::class);
124
- }
125
-
126
- return $ this ->ruleResource ;
127
- }
128
105
}
0 commit comments