Skip to content

Commit 3609dd2

Browse files
committed
MAGETWO-66588: [Backport] Perfomance toolkit generator improvement for 2.1
1 parent 6b3b524 commit 3609dd2

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public function execute()
355355
$this->query('quote_item', $order, $itemData);
356356
$this->query('quote_item_option', $order, $itemData, [
357357
'%code%' => 'info_buyRequest',
358-
'%value%' => json_encode([
358+
'%value%' => serialize([
359359
'product' => $productId($entityId, $i, Type::TYPE_SIMPLE),
360360
'qty' => "1",
361361
'uenc' => 'aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw'
@@ -555,6 +555,7 @@ private function getMaxEntityId($tableName, $resourceName, $column = 'entity_id'
555555
* @param string $typeId
556556
* @param int $limit
557557
* @return array
558+
* @throws \Exception
558559
*/
559560
private function getProductIds(\Magento\Store\Api\Data\StoreInterface $store, $typeId, $limit = null)
560561
{
@@ -572,8 +573,11 @@ private function getProductIds(\Magento\Store\Api\Data\StoreInterface $store, $t
572573
$productCollection->getSelect()->where(" type_id = '$typeId' ");
573574
$productCollection->getSelect()->where(" sku NOT LIKE 'Big%' ");
574575
}
575-
576-
return $productCollection->getAllIds($limit);
576+
$ids = $productCollection->getAllIds($limit);
577+
if ($limit && count($ids) < $limit) {
578+
throw new \Exception('Not enough products of type: ' . $typeId);
579+
}
580+
return $ids;
577581
}
578582

579583
/**
@@ -587,12 +591,13 @@ private function getProductIds(\Magento\Store\Api\Data\StoreInterface $store, $t
587591
private function prepareSimpleProducts(array $productIds = [])
588592
{
589593
$productsResult = [];
594+
590595
foreach ($productIds as $key => $simpleId) {
591596
$simpleProduct = $this->productRepository->getById($simpleId);
592597
$productsResult[$key]['id'] = $simpleId;
593598
$productsResult[$key]['sku'] = $simpleProduct->getSku();
594599
$productsResult[$key]['name'] = $simpleProduct->getName();
595-
$productsResult[$key]['buyRequest'] = json_encode([
600+
$productsResult[$key]['buyRequest'] = serialize([
596601
"info_buyRequest" => [
597602
"uenc" => "aHR0cDovL21hZ2VudG8uZGV2L2NvbmZpZ3VyYWJsZS1wcm9kdWN0LTEuaHRtbA,,",
598603
"product" => $simpleId,
@@ -667,13 +672,13 @@ private function prepareConfigurableProducts(array $productIds = [])
667672
$productsResult[$key]['name'] = $configurableProduct->getName();
668673
$productsResult[$key]['childId'] = $simpleId;
669674
$productsResult[$key]['buyRequest'] = [
670-
'order' => json_encode($configurableBuyRequest),
671-
'quote' => json_encode($quoteConfigurableBuyRequest),
672-
'super_attribute' => json_encode($superAttribute)
675+
'order' => serialize($configurableBuyRequest),
676+
'quote' => serialize($quoteConfigurableBuyRequest),
677+
'super_attribute' => serialize($superAttribute)
673678
];
674679
$productsResult[$key]['childBuyRequest'] = [
675-
'order' => json_encode($simpleBuyRequest),
676-
'quote' => json_encode($quoteSimpleBuyRequest),
680+
'order' => serialize($simpleBuyRequest),
681+
'quote' => serialize($quoteSimpleBuyRequest),
677682
];
678683
}
679684
return $productsResult;

0 commit comments

Comments
 (0)