Skip to content

Commit fc4cece

Browse files
committed
Merge branch 'ACP2E-1697' of https://github.com/magento-l3/magento2ce into PR-L3-03132023
2 parents c7464fe + 9b384a0 commit fc4cece

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

app/code/Magento/CatalogRule/Model/Rule.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,16 @@ public function callbackValidateProduct($args)
405405
$product->setData($args['row']);
406406

407407
$websites = $this->_getWebsitesMap();
408+
$websiteIds = $this->getWebsiteIds();
409+
if (!is_array($websiteIds)) {
410+
$websiteIds = explode(',', $websiteIds);
411+
}
408412
$results = [];
409413

410414
foreach ($websites as $websiteId => $defaultStoreId) {
415+
if (!in_array($websiteId, $websiteIds)) {
416+
continue;
417+
}
411418
$product->setStoreId($defaultStoreId);
412419
$results[$websiteId] = $this->getConditions()->validate($product);
413420
}

app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ public function testCallbackValidateProduct($validate): void
207207
'updated_at' => '2014-06-25 14:37:15'
208208
];
209209
$this->storeManager->expects($this->any())->method('getWebsites')->with(false)
210-
->willReturn([$this->websiteModel, $this->websiteModel]);
210+
->willReturn([$this->websiteModel, $this->websiteModel, $this->websiteModel]);
211211
$this->websiteModel
212212
->method('getId')
213-
->willReturnOnConsecutiveCalls('1', '2');
213+
->willReturnOnConsecutiveCalls('1', '2', '3');
214214
$this->websiteModel->expects($this->any())->method('getDefaultStore')
215215
->willReturn($this->storeModel);
216216
$this->storeModel
217217
->method('getId')
218-
->willReturnOnConsecutiveCalls('1', '2');
218+
->willReturnOnConsecutiveCalls('1', '2', '3');
219219
$this->combineFactory->expects($this->any())->method('create')
220220
->willReturn($this->condition);
221221
$this->condition->expects($this->any())->method('validate')
@@ -224,12 +224,14 @@ public function testCallbackValidateProduct($validate): void
224224
$this->productModel->expects($this->any())->method('getId')
225225
->willReturn(1);
226226

227+
$this->rule->setWebsiteIds('1,2');
227228
$this->rule->callbackValidateProduct($args);
228229

229230
$matchingProducts = $this->rule->getMatchingProductIds();
230231
foreach ($matchingProducts['1'] as $matchingRules) {
231232
$this->assertEquals($validate, $matchingRules);
232233
}
234+
$this->assertNull($matchingProducts['1']['3'] ?? null);
233235
}
234236

235237
/**

0 commit comments

Comments
 (0)