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.

asked Mar 15, 2019 at 6:01
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(); }

Jarnail S
4,70730 gold badges47 silver badges80 bronze badges
answered Nov 22, 2019 at 7:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.