João Ortiz
João Ortiz

Reputation: 11

Wrong Arguments in product_atribute.create on SOAP v1 Magento

Magento 1.9 API SOAP v1

I really need help! I'm tired of try to solve this...

The problem is when I try to call product_attribute.create.

    $arr = array('id_text',array(
        'frontend_input' => 'Voltage',
        'default_value' => '1',
        'is_configurable' => 0,
        'used_in_product_listing' => 0,
        'is_visible_on_front' => 0,
        'is_comparable' => 0,
        'is_used_for_promo_rules' => 0,
        'is_required' => 0,
        'scope' => 'store',
        'is_unique' => 0,
        'is_searchable' => 0,
        'attribute_code' => '12345',
        'is_visible_in_advanced_search' => 0,
        'frontend_label' => array('store_id' => '1', 'label' => '220V')
    ));

    try {
        $result = $soap->call($session, 'product_attribute.create',  $arr);
    } catch (SoapFault $e) {
        echo '<p style="color:red;">'.$e -> getMessage().'</p>';
        return false;
    }

The result returns nothing and stops the execution or when I remove the ID ('id_text') returns 102 - Invalid required parameters

Upvotes: 1

Views: 110

Answers (1)

Reena Parekh
Reena Parekh

Reputation: 941

Have you seen the product_attribute.create function in API ? It only takes one argument. Function can be referred at - app\code\core\Mage\Catalog\Model\Product\Attribute\Api.php --- create()

You are passing two arguments, first being id_text and second being your attribute data array. 2 arguments are only accepted by the product_attribute.update. In that API you have to pass first arguments as the attribute_code of the attribute that you want to update.

Can you try calling the product_attribute.create API with following array ?

$arr = array(
        'frontend_input' => 'Voltage',
        'default_value' => '1',
        'is_configurable' => 0,
        'used_in_product_listing' => 0,
        'is_visible_on_front' => 0,
        'is_comparable' => 0,
        'is_used_for_promo_rules' => 0,
        'is_required' => 0,
        'scope' => 'store',
        'is_unique' => 0,
        'is_searchable' => 0,
        'attribute_code' => '12345',
        'is_visible_in_advanced_search' => 0,
        'frontend_label' => array('store_id' => '1', 'label' => '220V')
    );

Upvotes: 1

Related Questions