Skip to content

Commit fb2ac0b

Browse files
committed
MC-17533: 'Apply Coupon To Cart' benchmark scenario fix
1 parent 6e534ad commit fb2ac0b

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

setup/src/Magento/Setup/Fixtures/CouponCodesFixture.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,54 +71,35 @@ public function execute()
7171

7272
/** @var \Magento\Store\Model\StoreManager $storeManager */
7373
$storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class);
74-
/** @var $category \Magento\Catalog\Model\Category */
75-
$category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class);
7674

7775
//Get all websites
78-
$categoriesArray = [];
76+
$websitesArray = [];
7977
$websites = $storeManager->getWebsites();
8078
foreach ($websites as $website) {
81-
//Get all groups
82-
$websiteGroups = $website->getGroups();
83-
foreach ($websiteGroups as $websiteGroup) {
84-
$websiteGroupRootCategory = $websiteGroup->getRootCategoryId();
85-
$category->load($websiteGroupRootCategory);
86-
$categoryResource = $category->getResource();
87-
//Get all categories
88-
$resultsCategories = $categoryResource->getAllChildren($category);
89-
foreach ($resultsCategories as $resultsCategory) {
90-
$category->load($resultsCategory);
91-
$structure = explode('/', $category->getPath());
92-
if (count($structure) > 2) {
93-
$categoriesArray[] = [$category->getId(), $website->getId()];
94-
}
95-
}
96-
}
79+
$websitesArray[] = $website->getId();
9780
}
98-
asort($categoriesArray);
99-
$categoriesArray = array_values($categoriesArray);
10081

101-
$this->generateCouponCodes($this->ruleFactory, $this->couponCodeFactory, $categoriesArray);
82+
$this->generateCouponCodes($this->ruleFactory, $this->couponCodeFactory, $websitesArray);
10283
}
10384

10485
/**
10586
* Generate Coupon Codes
10687
*
10788
* @param \Magento\SalesRule\Model\RuleFactory $ruleFactory
10889
* @param \Magento\SalesRule\Model\CouponFactory $couponCodeFactory
109-
* @param array $categoriesArray
90+
* @param array $websitesArray
11091
*
11192
* @return void
11293
*/
113-
public function generateCouponCodes($ruleFactory, $couponCodeFactory, $categoriesArray)
94+
public function generateCouponCodes($ruleFactory, $couponCodeFactory, $websitesArray)
11495
{
11596
for ($i = 0; $i < $this->couponCodesCount; $i++) {
11697
$ruleName = sprintf('Coupon Code %1$d', $i);
11798
$data = [
11899
'rule_id' => null,
119100
'name' => $ruleName,
120101
'is_active' => '1',
121-
'website_ids' => $categoriesArray[$i % count($categoriesArray)][1],
102+
'website_ids' => $websitesArray,
122103
'customer_group_ids' => [
123104
0 => '0',
124105
1 => '1',

0 commit comments

Comments
 (0)