1

I am trying to import the custom options with price 0 via backend. But it failed to save the price value with 0 and it throws an error like below.

Notice: Undefined offset: 6336 in /var/www/html/xx/vendor/magento/module-catalog-import-export/Model/Import/Product/Option.php on line 1474

By referring this link https://github.com/magento/magento2/commit/4c76f9a441a564ade8e904cd99eed0827162ff9c

I have replaced the code as shown in the below image.

enter image description here

Then the option is imported correctly.

Can you tell me is this the right way to edit the core file?

By doing this, will it cause any issue in custom options?

Please guide me in the right way. Thanks in advance.

1
  • id recommend u take a look to line 6335 and 6336 as that is were the issue lies Commented Mar 15, 2019 at 9:27

1 Answer 1

0

Some Code:

\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory $customOptionFactory

$options[$count] = [ 'title' => $singleTypeOption['option']['title'], 'type' => $singleTypeOption['option']['type'], 'is_require' => (int)$singleTypeOption['option']['is_require'], 'price' => 0, 'price_type' => 'fixed', 'sku' => '', 'max_characters' => 255, 'values' => array() ];

if(count($options)){ $customOptions = []; foreach ($options as $arrayOption) { $customOption = $this->customOptionFactory->create(); $customOption->setData($arrayOption); $customOption->setProductSku($product->getSku()); $customOptions[] = $customOption; } $product->setOptions($customOptions)->save(); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.