0

I'm having some problems importing custom options with the magmi datapump api. I can upload products with ease by passing the data in an array as given in magmi's example.

However when I install the Custom Options module and enable it I receive the following error.

...
$dp->beginImportSession("default","create");

// Here we define a single "simple" item, with name, sku,price,attribute_set,store,description
$item = array(
    'name'          => 'test a',
    'sku'           => 'testsku3',
    'price'         => '110.00',
    'attribute_set' => 'Default',
    'store'         => 'admin',
    'description'   => 'ingested with Datapump API',
    'meta_title'    => 'test meta',
    'qty'           => '1',
    'categories'    => '2',
    'weight'        => '1',
    'tax_class_id'  => '4',
    'Please enter your text:field:1:3' => ':fixed:0.5:Ref Text:35'
);

...

Error returned:

Notice: Undefined index: xxx:field:1 in /var/www/vhosts/websitename.co.uk/magmi/plugins/extra/itemprocessors/customoptions/pablo_customoptions.php on line 33

Now this error code resolves to...

...
public function getOptId($field)
{
    return $this->_optids[$field];
}
...

Does anyone have an idea as to how this can be resolved?

Thanks! :)

Rikkouri
  • 87
  • 2
  • 9

2 Answers2

1

the line

'Please enter your text:field:1:3' => ':fixed:0.5:Ref Text:35'

will create this error.

fix it by edit the php file

...
public function getOptId($field)
{
    if isset($this->_optids[$field]) return $this->_optids[$field];
    return '';
}
...

or BETTER "Please enter your text" like said in the script ;) replace this line with you custom attribute

'Please enter your text:field:1:3' => ':fixed:0.5:Ref Text:35'
EDIT TO:
'custom_attribute'             => 'value',

Simon

irokee
  • 80
  • 4
1

So I was having this same issue, and it was a massive headache. The above solution kind of worked, in that the product was created with no errors, but the custom option was not added.

However, I managed to create a solution!

I was attempting to add a custom option to my product using the following label:

date_time:field:1:1

This was throwing the exact same error that you were having. However, it's formatted as it should be.

To solve it, I had to edit the file: /magmi/plugins/extra/itemprocessors/customoptions/pablo_customoptions.php

I change the getOptId() function (line 30) to:

public function getOptId($field)
{
    if(isset($this->_optids[$field])){
        return $this->_optids[$field];
    } else {
        return false;
    }
}

And made a change in the createOption() function (now on line 74). I changed if(!isset($optionId)) to if(!$optionId)

And bingo, it should now work as expected!

James Kemp
  • 349
  • 1
  • 8