@@ -213,14 +213,16 @@ protected function cleanByIds($productIds)
213
213
{
214
214
$ this ->connection ->deleteFromSelect (
215
215
$ this ->connection
216
- ->select ($ this ->resource ->getTableName ('catalogrule_product ' ), 'product_id ' )
216
+ ->select ()
217
+ ->from ($ this ->resource ->getTableName ('catalogrule_product ' ), 'product_id ' )
217
218
->distinct ()
218
219
->where ('product_id IN (?) ' , $ productIds ),
219
220
$ this ->resource ->getTableName ('catalogrule_product ' )
220
221
);
221
222
222
223
$ this ->connection ->deleteFromSelect (
223
- $ this ->connection ->select ($ this ->resource ->getTableName ('catalogrule_product_price ' ), 'product_id ' )
224
+ $ this ->connection ->select ()
225
+ ->from ($ this ->resource ->getTableName ('catalogrule_product_price ' ), 'product_id ' )
224
226
->distinct ()
225
227
->where ('product_id IN (?) ' , $ productIds ),
226
228
$ this ->resource ->getTableName ('catalogrule_product_price ' )
@@ -240,6 +242,10 @@ protected function applyRule(Rule $rule, $product)
240
242
$ productId = $ product ->getId ();
241
243
$ websiteIds = array_intersect ($ product ->getWebsiteIds (), $ rule ->getWebsiteIds ());
242
244
245
+ if (!$ rule ->validate ($ product )) {
246
+ return $ this ;
247
+ }
248
+
243
249
$ this ->connection ->delete (
244
250
$ this ->resource ->getTableName ('catalogrule_product ' ),
245
251
[
@@ -248,14 +254,6 @@ protected function applyRule(Rule $rule, $product)
248
254
]
249
255
);
250
256
251
- if (!$ rule ->validate ($ product )) {
252
- $ this ->connection ->delete (
253
- $ this ->resource ->getTableName ('catalogrule_product_price ' ),
254
- [$ this ->connection ->quoteInto ('product_id = ? ' , $ productId )]
255
- );
256
- return $ this ;
257
- }
258
-
259
257
$ customerGroupIds = $ rule ->getCustomerGroupIds ();
260
258
$ fromTime = strtotime ($ rule ->getFromDate ());
261
259
$ toTime = strtotime ($ rule ->getToDate ());
0 commit comments