13
13
14
14
use Magento \Catalog \Model \Attribute \ScopeOverriddenValue ;
15
15
16
+ /**
17
+ * Backend model for Tierprice attribute
18
+ */
16
19
class Tierprice extends \Magento \Catalog \Model \Product \Attribute \Backend \GroupPrice \AbstractGroupPrice
17
20
{
18
21
/**
@@ -159,8 +162,22 @@ protected function validatePrice(array $priceRow)
159
162
*/
160
163
protected function modifyPriceData ($ object , $ data )
161
164
{
165
+ /** @var \Magento\Catalog\Model\Product $object */
162
166
$ data = parent ::modifyPriceData ($ object , $ data );
163
167
$ price = $ object ->getPrice ();
168
+
169
+ $ specialPrice = $ object ->getSpecialPrice ();
170
+ $ specialPriceFromDate = $ object ->getSpecialFromDate ();
171
+ $ specialPriceToDate = $ object ->getSpecialToDate ();
172
+ $ today = time ();
173
+
174
+ if ($ specialPrice && ($ object ->getPrice () > $ object ->getFinalPrice ())) {
175
+ if ($ today >= strtotime ($ specialPriceFromDate ) && $ today <= strtotime ($ specialPriceToDate ) ||
176
+ $ today >= strtotime ($ specialPriceFromDate ) && $ specialPriceToDate === null ) {
177
+ $ price = $ specialPrice ;
178
+ }
179
+ }
180
+
164
181
foreach ($ data as $ key => $ tierPrice ) {
165
182
$ percentageValue = $ this ->getPercentage ($ tierPrice );
166
183
if ($ percentageValue ) {
@@ -172,6 +189,10 @@ protected function modifyPriceData($object, $data)
172
189
}
173
190
174
191
/**
192
+ * Update Price values in DB
193
+ *
194
+ * Updates price values in DB from array comparing to old values. Returns bool if updated
195
+ *
175
196
* @param array $valuesToUpdate
176
197
* @param array $oldValues
177
198
* @return boolean
0 commit comments