@@ -355,7 +355,7 @@ public function execute()
355
355
$ this ->query ('quote_item ' , $ order , $ itemData );
356
356
$ this ->query ('quote_item_option ' , $ order , $ itemData , [
357
357
'%code% ' => 'info_buyRequest ' ,
358
- '%value% ' => json_encode ([
358
+ '%value% ' => serialize ([
359
359
'product ' => $ productId ($ entityId , $ i , Type::TYPE_SIMPLE ),
360
360
'qty ' => "1 " ,
361
361
'uenc ' => 'aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw '
@@ -555,6 +555,7 @@ private function getMaxEntityId($tableName, $resourceName, $column = 'entity_id'
555
555
* @param string $typeId
556
556
* @param int $limit
557
557
* @return array
558
+ * @throws \Exception
558
559
*/
559
560
private function getProductIds (\Magento \Store \Api \Data \StoreInterface $ store , $ typeId , $ limit = null )
560
561
{
@@ -572,8 +573,11 @@ private function getProductIds(\Magento\Store\Api\Data\StoreInterface $store, $t
572
573
$ productCollection ->getSelect ()->where (" type_id = ' $ typeId' " );
573
574
$ productCollection ->getSelect ()->where (" sku NOT LIKE 'Big%' " );
574
575
}
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 ;
577
581
}
578
582
579
583
/**
@@ -587,12 +591,13 @@ private function getProductIds(\Magento\Store\Api\Data\StoreInterface $store, $t
587
591
private function prepareSimpleProducts (array $ productIds = [])
588
592
{
589
593
$ productsResult = [];
594
+
590
595
foreach ($ productIds as $ key => $ simpleId ) {
591
596
$ simpleProduct = $ this ->productRepository ->getById ($ simpleId );
592
597
$ productsResult [$ key ]['id ' ] = $ simpleId ;
593
598
$ productsResult [$ key ]['sku ' ] = $ simpleProduct ->getSku ();
594
599
$ productsResult [$ key ]['name ' ] = $ simpleProduct ->getName ();
595
- $ productsResult [$ key ]['buyRequest ' ] = json_encode ([
600
+ $ productsResult [$ key ]['buyRequest ' ] = serialize ([
596
601
"info_buyRequest " => [
597
602
"uenc " => "aHR0cDovL21hZ2VudG8uZGV2L2NvbmZpZ3VyYWJsZS1wcm9kdWN0LTEuaHRtbA,, " ,
598
603
"product " => $ simpleId ,
@@ -667,13 +672,13 @@ private function prepareConfigurableProducts(array $productIds = [])
667
672
$ productsResult [$ key ]['name ' ] = $ configurableProduct ->getName ();
668
673
$ productsResult [$ key ]['childId ' ] = $ simpleId ;
669
674
$ 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 )
673
678
];
674
679
$ productsResult [$ key ]['childBuyRequest ' ] = [
675
- 'order ' => json_encode ($ simpleBuyRequest ),
676
- 'quote ' => json_encode ($ quoteSimpleBuyRequest ),
680
+ 'order ' => serialize ($ simpleBuyRequest ),
681
+ 'quote ' => serialize ($ quoteSimpleBuyRequest ),
677
682
];
678
683
}
679
684
return $ productsResult ;
0 commit comments