Skip to content

Commit 24d6516

Browse files
committed
MAGETWO-96498: Gift Card Account
1 parent 34e270b commit 24d6516

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public function execute()
127127
$fixtureMap = [
128128
'name' => $variationSkuClosure,
129129
'sku' => $variationSkuClosure,
130-
'price' => function () {
131-
return $this->priceProvider->getPrice();
130+
'price' => function ($index, $entityNumber) {
131+
return $this->priceProvider->getPrice($entityNumber);
132132
},
133133
'website_ids' => function ($index, $entityNumber) use ($variationCount) {
134134
$configurableIndex = $this->getBundleProductIndex($entityNumber, $variationCount);
@@ -166,8 +166,8 @@ public function execute()
166166
'meta_title' => $skuClosure,
167167
'price' => function ($index) use ($priceTypeClosure) {
168168
return $priceTypeClosure($index) === LinkInterface::PRICE_TYPE_PERCENT
169-
? random_int(10, 90)
170-
: $this->priceProvider->getPrice();
169+
? mt_rand(10, 90)
170+
: $this->priceProvider->getPrice($index);
171171
},
172172
'priceType' => $priceTypeClosure,
173173
'website_ids' => function ($index, $entityNumber) {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ public function execute()
247247
$fixture = [
248248
'name' => $variationSkuClosure,
249249
'sku' => $variationSkuClosure,
250-
'price' => function () {
251-
return $this->priceProvider->getPrice();
250+
'price' => function ($index, $entityNumber) {
251+
return $this->priceProvider->getPrice($entityNumber);
252252
},
253253
'website_ids' => function ($index, $entityNumber) use ($variationCount) {
254254
$configurableIndex = $this->getConfigurableProductIndex($entityNumber, $variationCount);
@@ -312,9 +312,10 @@ private function getDefaultAttributeSetsConfig(array $defaultAttributeSets, $con
312312
{
313313
$attributeSetClosure = function ($index) use ($defaultAttributeSets) {
314314
$attributeSetAmount = count(array_keys($defaultAttributeSets));
315+
mt_srand($index);
315316

316317
return $attributeSetAmount > ($index - 1) % (int)$this->fixtureModel->getValue('categories', 30)
317-
? array_keys($defaultAttributeSets)[random_int(0, $attributeSetAmount - 1)]
318+
? array_keys($defaultAttributeSets)[mt_rand(0, $attributeSetAmount - 1)]
318319
: 'Default';
319320
};
320321
$productsPerSet = [];
@@ -864,6 +865,7 @@ private function getDescriptionClosure(
864865
$configurableProductsCount / ($simpleProductsCount + $configurableProductsCount)
865866
)
866867
);
868+
mt_srand($index);
867869
return $this->dataGenerator->generate(
868870
$minAmountOfWordsDescription,
869871
$maxAmountOfWordsDescription,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function generate($config)
5151

5252
$image = imagecreate($config['image-width'], $config['image-height']);
5353
$bgColor = imagecolorallocate($image, 240, 240, 240);
54-
$fgColor = imagecolorallocate($image, random_int(0, 230), random_int(0, 230), random_int(0, 230));
54+
$fgColor = imagecolorallocate($image, mt_rand(0, 230), mt_rand(0, 230), mt_rand(0, 230));
5555
$colors = [$fgColor, $bgColor];
5656
imagefilledrectangle($image, 0, 0, $config['image-width'], $config['image-height'], $bgColor);
5757

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ public function execute()
311311
while ($entityId <= $requestedOrders) {
312312
$batchNumber++;
313313
$productCount = [
314-
Type::TYPE_SIMPLE => random_int($orderSimpleCountFrom, $orderSimpleCountTo),
315-
Configurable::TYPE_CODE => random_int($orderConfigurableCountFrom, $orderConfigurableCountTo),
316-
self::BIG_CONFIGURABLE_TYPE => random_int($orderBigConfigurableCountFrom, $orderBigConfigurableCountTo)
314+
Type::TYPE_SIMPLE => mt_rand($orderSimpleCountFrom, $orderSimpleCountTo),
315+
Configurable::TYPE_CODE => mt_rand($orderConfigurableCountFrom, $orderConfigurableCountTo),
316+
self::BIG_CONFIGURABLE_TYPE => mt_rand($orderBigConfigurableCountFrom, $orderBigConfigurableCountTo)
317317
];
318318
$order = [
319319
'%itemsPerOrder%' => array_sum($productCount),

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ class PriceProvider
1414
/**
1515
* Get random price for product
1616
*
17+
* @param int $productIndex
1718
* @return float
1819
*/
19-
public function getPrice()
20+
public function getPrice($productIndex)
2021
{
21-
switch (random_int(0, 3)) {
22+
mt_srand($productIndex);
23+
switch (mt_rand(0, 3)) {
2224
case 0:
2325
return 9.99;
2426
case 1:
2527
return 5;
2628
case 2:
2729
return 1;
2830
case 3:
29-
return random_int(1, 10000) / 10;
31+
return mt_rand(1, 10000) / 10;
3032
}
3133
}
3234
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ public function execute()
186186

187187
$additionalAttributeSets = $this->getAdditionalAttributeSets();
188188
$attributeSet = function ($index) use ($defaultAttributeSets, $additionalAttributeSets) {
189+
mt_srand($index);
189190
$attributeSetCount = count(array_keys($defaultAttributeSets));
190191
if ($attributeSetCount > (($index - 1) % (int)$this->fixtureModel->getValue('categories', 30))) {
191-
return array_keys($defaultAttributeSets)[random_int(0, count(array_keys($defaultAttributeSets)) - 1)];
192+
return array_keys($defaultAttributeSets)[mt_rand(0, count(array_keys($defaultAttributeSets)) - 1)];
192193
} else {
193194
$customSetsAmount = count($additionalAttributeSets);
194195
return $customSetsAmount
@@ -205,9 +206,10 @@ public function execute()
205206
$additionalAttributeSets
206207
) {
207208
$attributeValues = [];
209+
mt_srand($index);
208210
if (isset($defaultAttributeSets[$attributeSetId])) {
209211
foreach ($defaultAttributeSets[$attributeSetId] as $attributeCode => $values) {
210-
$attributeValues[$attributeCode] = $values[random_int(0, count($values) - 1)];
212+
$attributeValues[$attributeCode] = $values[mt_rand(0, count($values) - 1)];
211213
}
212214
}
213215

@@ -221,8 +223,8 @@ public function execute()
221223
'sku' => function ($productId) {
222224
return sprintf($this->getSkuPattern(), $productId);
223225
},
224-
'price' => function () {
225-
return $this->priceProvider->getPrice();
226+
'price' => function ($index, $entityNumber) {
227+
return $this->priceProvider->getPrice($entityNumber);
226228
},
227229
'url_key' => function ($productId) {
228230
return sprintf('simple-product-%s', $productId);

0 commit comments

Comments
 (0)