1

I'm busy to make an import script that can import over 11.000 products from one feed with SOAP V2

Now i already made the import for the category's and subcategory's working like a charm with SOAP

After that i had made a part to add simple products into the shop what's working fine. The products are getting imported, so thats ok, but...

After that i need to import 15 additional_attributes that i already have made in the backoffice as attrubute and putted them in a map Extra.

Now i'm trying to expand my script to add the additional_attributes, but everything what i'm trying is not working. Every tip on the internet i have tryed didn;t worked out.

For the rest is the information verry poor on the website of Magento self how to make the correct array for the additional_attributes.

I have tryed about 6 different arrays to make this work, all the arrays were standing in the internet, but nothing is working. I'm now working about 20 hours on this and its nerving me out!

Is there a genious person that can help me through this problem? Or someone whants to share the golden tip how to do this...

$result = $client->catalogProductCreate($session, 'simple', $attribute_set_id, $artnr, array(
        'categories' => array($aProdCatId['entity_id']),
        'websites' => array(1),
        'name' => $titel,
        'description' => $descr,
        'short_description' => $descr,
        'weight' => $weight,
        'status' => '1',
        'url_key' => $title,
        'url_path' => $title,
        'visibility' => '4',
        'price' => $adviceprice,
        'tax_class_id' => 1,
        'meta_title' => $title,
        'meta_keyword' => $title,
        'meta_description' => $title,
        'additional_attributes' => array(array('power' => $power))
    ));

closed as off-topic by David Manners, Vladimir Kerkhoff, Moose, Keyul Shah, brentwpeterson Nov 18 '14 at 13:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced OR seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – David Manners, Vladimir Kerkhoff, Moose, Keyul Shah, brentwpeterson
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Tested with array array('key' => 'merk', 'value' => (string)$merk) // Product imported YES | Attributes imported NO – Martin Meijer Aug 7 '14 at 8:27
  • Tested with array array(array('key' => 'merk', 'value' => (string)$merk)) // Product imported YES | Attributes imported NO – Martin Meijer Aug 7 '14 at 8:30
  • Tested with array array(array('merk' => (string)$merk)) // Product imported YES | Attributes imported NO – Martin Meijer Aug 7 '14 at 8:39
  • Tested with array array('merk' => (string)$merk) // Product imported YES | Attributes imported NO – Martin Meijer Aug 7 '14 at 8:43
  • Tested with array array('multi_data' => array('key' =>'merk', 'value' => (string)$merk)) // Error Uncaught SoapFault exception: [SOAP-ENV:Server] Cannot access empty property in – Martin Meijer Aug 7 '14 at 8:59
2

I think you need to send the additional_attributes as an array of arrays. And each second level array must contain a key and value property.
Something like this:

'additional_attributes' => array(
    array('key'=>'power', 'value'=>$power),
    array('key'=>'other_attribute', 'value'=>$otherAttributeValue),
)

[EDIT]
Looking through the Mage_Catalog_Model_Product_Api_V2::_prepareDataForSave method I found this:

   if (property_exists($productData, 'additional_attributes')) {
        if (property_exists($productData->additional_attributes, 'single_data')) {
            foreach ($productData->additional_attributes->single_data as $_attribute) {
                $_attrCode = $_attribute->key;
                $productData->$_attrCode = $_attribute->value;
            }
        }
        if (property_exists($productData->additional_attributes, 'multi_data')) {
            foreach ($productData->additional_attributes->multi_data as $_attribute) {
                $_attrCode = $_attribute->key;
                $productData->$_attrCode = $_attribute->value;
            }
        }
        unset($productData->additional_attributes);
    }

I conclude from this that you need an other level in the array I mentioned above.
So try it like this:

'additional_attributes' => array(
    'single_data' =>  array('key'=>'power', 'value'=>$power),
)

or

'additional_attributes' => array(
    'multi_data' =>  array('key'=>'power', 'value'=>$power),
)

Try this new approach.

  • Hi Marius, Thanks for the fast reply I have tested this yesterday for sure i did it again, but no success the product has been imported without erros and the extra attributes – Martin Meijer Aug 7 '14 at 8:26
  • I have tested a few arrays now without any success, you can see the arrays that i have tested as a commenth in my post – Martin Meijer Aug 7 '14 at 8:41
  • @MartinMeijer. I found something else. I edited the answer. Give that a try. – Marius Aug 7 '14 at 8:46
  • i tryed both ways but i'm getting the same error on this (also tryed this yesterday, it's something like a pane in the ass to get this) Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Cannot access empty property in xxx/importSimpleProduct.php:81 Stack trace: #0 xxx/importSimpleProduct.php(81): SoapClient->__call('catalogProductC...', Array) #1 xxx/importSimpleProduct.php(81): SoapClient->catalogProductCreate('edbe4882d120908...', 'simple', 11, Object(SimpleXMLElement), Array) #2 xxx/import.php(97): include('/home/account/d...') #3 {main} – Martin Meijer Aug 7 '14 at 8:52
  • In meanwhile i've discoverd that the array is reaching the right part of the script. The array is invalid i made a testscript with the same array and how the array gets appart in the magento script. If i test this, i'm getting a simular PHP error! This makes sense... now the solution! <?php $productData = array('additional_attributes' => array('key' => 'foo', 'value' => "bar")); echo "<pre>"; print_r($productData); echo "</pre>"; foreach ($productData->additional_attributes->multi_data as $_attribute) { echo $_attribute->key."<br />"; echo $_attribute->value."<br />"; } ?> – Martin Meijer Aug 7 '14 at 11:12

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