Skip to content

Commit 14188dc

Browse files
ENGCOM-6213: Fixed: Undefined index store_view_code. #25080
2 parents 4688bba + 3346d54 commit 14188dc

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,9 @@ protected function _parseCustomOptions($rowData)
20862086
}
20872087
}
20882088
}
2089-
$options[$name][$k]['_custom_option_store'] = $rowData[Product::COL_STORE_VIEW_CODE];
2089+
if (isset($rowData[Product::COL_STORE_VIEW_CODE])) {
2090+
$options[$name][$k][self::COLUMN_STORE] = $rowData[Product::COL_STORE_VIEW_CODE];
2091+
}
20902092
$k++;
20912093
}
20922094
$rowData['custom_options'] = $options;

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,77 @@ public function testValidateAmbiguousData(
776776
$this->assertEquals($errors, $resultErrors);
777777
}
778778

779+
/**
780+
* Test for row without store view code field
781+
* @param array $rowData
782+
* @param array $responseData
783+
*
784+
* @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_parseCustomOptions
785+
* @dataProvider validateRowStoreViewCodeFieldDataProvider
786+
*/
787+
public function testValidateRowDataForStoreViewCodeField($rowData, $responseData)
788+
{
789+
$reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\Option::class);
790+
$reflectionMethod = $reflection->getMethod('_parseCustomOptions');
791+
$reflectionMethod->setAccessible(true);
792+
$result = $reflectionMethod->invoke($this->model, $rowData);
793+
$this->assertEquals($responseData, $result);
794+
}
795+
796+
/**
797+
* Data provider for test of method _parseCustomOptions
798+
*
799+
* @return array
800+
*/
801+
public function validateRowStoreViewCodeFieldDataProvider()
802+
{
803+
return [
804+
'with_store_view_code' => [
805+
'$rowData' => [
806+
'store_view_code' => '',
807+
'custom_options' =>
808+
'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
809+
],
810+
'$responseData' => [
811+
'store_view_code' => '',
812+
'custom_options' => [
813+
'Test Field Title' => [
814+
[
815+
'name' => 'Test Field Title',
816+
'type' => 'field',
817+
'required' => '1',
818+
'sku' => '1-text',
819+
'price' => '0',
820+
'price_type' => 'fixed',
821+
'_custom_option_store' => ''
822+
]
823+
]
824+
]
825+
],
826+
],
827+
'without_store_view_code' => [
828+
'$rowData' => [
829+
'custom_options' =>
830+
'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
831+
],
832+
'$responseData' => [
833+
'custom_options' => [
834+
'Test Field Title' => [
835+
[
836+
'name' => 'Test Field Title',
837+
'type' => 'field',
838+
'required' => '1',
839+
'sku' => '1-text',
840+
'price' => '0',
841+
'price_type' => 'fixed'
842+
]
843+
]
844+
]
845+
],
846+
]
847+
];
848+
}
849+
779850
/**
780851
* Data provider of row data and errors
781852
*

0 commit comments

Comments
 (0)