1
1
<?php
2
-
3
2
/**
4
- * Import entity of bundle product type
5
- *
6
3
* Copyright © Magento, Inc. All rights reserved.
7
4
* See COPYING.txt for license details.
8
5
*/
@@ -29,25 +26,25 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
29
26
/**
30
27
* Delimiter before product option value.
31
28
*/
32
- const BEFORE_OPTION_VALUE_DELIMITER = '; ' ;
29
+ public const BEFORE_OPTION_VALUE_DELIMITER = '; ' ;
33
30
34
- const PAIR_VALUE_SEPARATOR = '= ' ;
31
+ public const PAIR_VALUE_SEPARATOR = '= ' ;
35
32
36
33
/**
37
34
* Dynamic value.
38
35
*/
39
- const VALUE_DYNAMIC = 'dynamic ' ;
36
+ public const VALUE_DYNAMIC = 'dynamic ' ;
40
37
41
38
/**
42
39
* Fixed value.
43
40
*/
44
- const VALUE_FIXED = 'fixed ' ;
41
+ public const VALUE_FIXED = 'fixed ' ;
45
42
46
- const NOT_FIXED_DYNAMIC_ATTRIBUTE = 'price_view ' ;
43
+ public const NOT_FIXED_DYNAMIC_ATTRIBUTE = 'price_view ' ;
47
44
48
- const SELECTION_PRICE_TYPE_FIXED = 0 ;
45
+ public const SELECTION_PRICE_TYPE_FIXED = 0 ;
49
46
50
- const SELECTION_PRICE_TYPE_PERCENT = 1 ;
47
+ public const SELECTION_PRICE_TYPE_PERCENT = 1 ;
51
48
52
49
/**
53
50
* Array of cached options.
@@ -89,9 +86,9 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
89
86
];
90
87
91
88
/**
92
- * Custom fields mapping.
89
+ * Custom fields mapping for bundle product .
93
90
*
94
- * @inherited
91
+ * @var array
95
92
*/
96
93
protected $ _customFieldsMapping = [
97
94
'price_type ' => 'bundle_price_type ' ,
@@ -102,7 +99,7 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
102
99
];
103
100
104
101
/**
105
- * Bundle field mapping.
102
+ * Bundle field mapping for bundle product with selection .
106
103
*
107
104
* @var array
108
105
*/
@@ -113,7 +110,7 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
113
110
];
114
111
115
112
/**
116
- * Option type mapping.
113
+ * Option type mapping for bundle product .
117
114
*
118
115
* @var array
119
116
*/
@@ -202,11 +199,7 @@ protected function parseSelections($rowData, $entityId)
202
199
$ this ->_cachedOptions [$ entityId ][$ option ['name ' ]]['selections ' ] = [];
203
200
}
204
201
$ this ->_cachedOptions [$ entityId ][$ option ['name ' ]]['selections ' ][] = $ option ;
205
- $ this ->_cachedOptionSelectQuery [] =
206
- $ this ->connection ->quoteInto (
207
- '(parent_id = ' . (int )$ entityId . ' AND title = ?) ' ,
208
- $ option ['name ' ]
209
- );
202
+ $ this ->_cachedOptionSelectQuery [] = [(int )$ entityId , $ option ['name ' ]];
210
203
}
211
204
}
212
205
return $ selections ;
@@ -477,18 +470,24 @@ protected function transformBundleCustomAttributes($rowData)
477
470
*/
478
471
protected function populateExistingOptions ()
479
472
{
480
- $ existingOptions = $ this ->connection ->fetchAssoc (
481
- $ this ->connection ->select ()->from (
482
- ['bo ' => $ this ->_resource ->getTableName ('catalog_product_bundle_option ' )],
483
- ['option_id ' , 'parent_id ' , 'required ' , 'position ' , 'type ' ]
484
- )->joinLeft (
485
- ['bov ' => $ this ->_resource ->getTableName ('catalog_product_bundle_option_value ' )],
486
- 'bo.option_id = bov.option_id ' ,
487
- ['value_id ' , 'title ' ]
488
- )->where (
489
- implode (' OR ' , $ this ->_cachedOptionSelectQuery )
490
- )
473
+ $ select = $ this ->connection ->select ()->from (
474
+ ['bo ' => $ this ->_resource ->getTableName ('catalog_product_bundle_option ' )],
475
+ ['option_id ' , 'parent_id ' , 'required ' , 'position ' , 'type ' ]
476
+ )->joinLeft (
477
+ ['bov ' => $ this ->_resource ->getTableName ('catalog_product_bundle_option_value ' )],
478
+ 'bo.option_id = bov.option_id ' ,
479
+ ['value_id ' , 'title ' ]
491
480
);
481
+ $ orWhere = false ;
482
+ foreach ($ this ->_cachedOptionSelectQuery as $ item ) {
483
+ if ($ orWhere ) {
484
+ $ select ->orWhere ('parent_id = ' .$ item [0 ].' AND title = ? ' , $ item [1 ]);
485
+ } else {
486
+ $ select ->where ('parent_id = ' .$ item [0 ].' AND title = ? ' , $ item [1 ]);
487
+ $ orWhere = true ;
488
+ }
489
+ }
490
+ $ existingOptions = $ this ->connection ->fetchAssoc ($ select );
492
491
foreach ($ existingOptions as $ optionId => $ option ) {
493
492
$ this ->_cachedOptions [$ option ['parent_id ' ]][$ option ['title ' ]]['option_id ' ] = $ optionId ;
494
493
foreach ($ option as $ key => $ value ) {
0 commit comments