Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken API V2 with Magento 1.7.0.2 #4

Closed
hadl opened this issue Jun 17, 2013 · 16 comments
Closed

Broken API V2 with Magento 1.7.0.2 #4

hadl opened this issue Jun 17, 2013 · 16 comments

Comments

@hadl
Copy link

hadl commented Jun 17, 2013

Awesome script!!
Unfortunately it doesn't work for me with Magento 1.7.0.2.

I'm using API_V2 and always get the error "SOAP-ERROR: Encoding: object has no 'key' property" when trying your example.
The 'price_changes' array kills it somehow.
If i use the WSI price_changes array with the API call, it ends with a "array to string conversion" notice and "SOAP-ERROR: Encoding: string 'Cannot use object of type stdClass\xe0...' is not a valid utf-8 string".

Need some help :/

Thanks,
Andi

@jreinke
Copy link
Owner

jreinke commented Jun 24, 2013

Hello Andi,

Difficult for me to help you since examples given in blog were working fine but it was tested in PHP. What are ou using to make calls to Magento API?
Is it possible to reproduce easily the bug you have?

@hadl
Copy link
Author

hadl commented Jun 25, 2013

Hello Johann,

thanks for your answer.

I'm calling the API via PHP 5.4.
I just used your V2 example and got these errors.

Meanwhile i made some changes in your extension to the v2 api and it works now. It's also possible to update the associated products/prices with my version.
We are still testing the calls and if everything works in production i will send you the changes.
But i removed the "use attribute option name" feature and sticked to ids.

I have found the errors in your WSDL definition.
Check your element 'price_changes' type. It is type="typens:associativeArray" but i think it should be type="typens:complexMultiArray". At least this works for me now.
The foreach loops in _initConfigurableAttributesData() will change with this setting.

@deniscsz
Copy link

Hello @hadl, maybe could you post your changes to our? I have this problem too. Thanks

@serifreedom
Copy link

Hello @hadl , Where do you post the patch? I really need it, please...

@hadl
Copy link
Author

hadl commented Jan 15, 2015

Sorry for the "delay" 👎

I pushed my changes to hadl@9f78922

Difference to the original description:
You have to set the price_changes via

'price_changes' => array(
        array(
            'key'   => 'color',
            'value' => array(
                array(
                    'key'   => 25, // attribute id
                    'value' => '0',
                ),
            )
        )

Note: It was working for us but we switched to the simple configurable product extension and don't need the price changes anymore. The normal price changes method wasn' working for our price changes.

@Chandu9012
Copy link

Hello @hadl , I used your updated code but it still give me error can you please help me I am testing it in Magento 1.9.1 and usin Soap V2

Error : Fatal error: SOAP-ERROR: Encoding: object has no 'key' property in F:\wamp\www\webservices\catalog product\createproduct.php on line 100

Thanks

@hadl
Copy link
Author

hadl commented Aug 19, 2015

@Chandu9012 how does your SOAP call looks like?
Have you cleared the Magento and/or the PHP WSDL Cache?

@Chandu9012
Copy link

Below is code for SOAP call

login('soap_user', 'soap123'); $attributeSets = $client->catalogProductAttributeSetList($session); $attributeSet = current($attributeSets); $set = $attributeSet->set_id; $productData = array( 'name' => 'Name of product #1', 'description' => 'Description of product #1', 'short_description' => 'Short description of product #1', 'website_ids' => array('base'), // Id or code of website 'status' => 1, // 1 = Enabled, 2 = Disabled 'visibility' => 1, // 1 = Not visible, 2 = Catalog, 3 = Search, 4 = Catalog/Search 'tax_class_id' => 2, // Default VAT 'weight' => 0, 'stock_data' => array( 'use_config_manage_stock' => 1, 'manage_stock' => 1, // We do not manage stock, for example 'qty' => 10 ), 'price' => 9.90, // Same price than configurable product, no price change 'additional_attributes' => array( 'single_data' => array( array( 'key' => 'color', 'value' => 'Blue', // Id or label of color, attribute that will be used to configure product ), ), ) ); // Creation of product #1 $client->catalogProductCreate($session, 'simple', $set, 'SKU-001', $productData); /** - Simple product #2 (sku : SKU-002) */ $productData = array( 'name' => 'Name of product #2', 'description' => 'Description of product #2', 'short_description' => 'Short description of product #2', 'website_ids' => array('base'), // Id or code of website 'status' => 1, // 1 = Enabled, 2 = Disabled 'visibility' => 1, // 1 = Not visible, 2 = Catalog, 3 = Search, 4 = Catalog/Search 'tax_class_id' => 2, // Default VAT 'weight' => 0, 'stock_data' => array( 'use_config_manage_stock' => 1, 'manage_stock' => 1, // We do not manage stock, for example 'qty' => 20 ), 'price' => 8.90, // Red product is $1 less than configurable product 'additional_attributes' => array( 'single_data' => array( array( 'key' => 'color', 'value' => 'Red', // Id or label of color, attribute that will be used to configure product ), ), ) ); // Creation of product #2 $client->catalogProductCreate($session, 'simple', $set, 'SKU-002', $productData); /** - Configurable product */ $productData = array( 'name' => 'Configurable product', 'description' => 'Description of configurable product', 'short_description' => 'Short description of configurable product', 'website_ids' => array('base'), // Id or code of website 'status' => 1, // 1 = Enabled, 2 = Disabled 'visibility' => 4, // 1 = Not visible, 2 = Catalog, 3 = Search, 4 = Catalog/Search 'tax_class_id' => 2, // Default VAT 'weight' => 0, 'stock_data' => array( 'use_config_manage_stock' => 1, 'manage_stock' => 1, // We do not manage stock, for example 'qty' => 25, ), 'price' => 9.90, 'associated_skus' => array('SKU-001', 'SKU-002'), // Simple products to associate 'price_changes' => array( array( 'color' => array( 'Red' => '2', 'Blue' => '-10%' ) ) ) ); // Creation of configurable product //$result = $client->call($session, 'product.create', array('configurable', $attributeSet->set_id, 'SKU-TEST', $productData)); $result = $client->catalogProductCreate($session, 'configurable',$set, 'SKU-003',$productData); var_dump ($result); Thanks Chandu Mer

@hadl
Copy link
Author

hadl commented Aug 19, 2015

You have to use the attribute id for the price changes. See #4 (comment)

Here is a working example of our client:

$productData = array(
    'categories'        => array($categories),
    'websites'          => array(1),
    'name'              => 'Name',
    'description'       => 'lorem ipsum',
    'short_description' => 'lorem ipsum',
    'status'            => 1,
    'visibility'        => 4,
    'tax_class_id'      => 1, //19%
    'price'             => '1,40',
    'associated_skus'   => array(1,2), 
    'configurable_attributes' => array(158), // attribute id for sta_size
    'price_changes' => array(
        array(
            'key' => 'sta_size',
            'value' => array(
                array(
                    'key' => 42,    // 5 cm
                    'value' => '0', 
                ),
                array(
                    'key' => 43,    // 7 cm
                    'value' => '0', 
                ),
                array(
                    'key' => 45,      // 9 cm
                    'value' => '1,80',
                ),
            ),
        ),
    ),
    'additional_attributes' => array(
        'single_data' => array(
            array(
                'key'   => 'sta_material',
                'value' => 33,
            ),
        ),
        'multi_data' => array(
            array(
                'key'   => 'sta_pictogram',
                'value' => array(5, 6),
            ),
        )
    )

);

@Chandu9012
Copy link

I have updated SOAP Call as per See #4 (comment) and products created 2 simple and 1 configurable products but simple products are not assign to configurable products in Associated products

Can you please help me what is issue?

Thanks

@hadl
Copy link
Author

hadl commented Aug 19, 2015

Maybe because you haven't set 'configurable_attributes'?
Guess you have to xdebug.

@hadl hadl closed this as completed Aug 19, 2015
@Chandu9012
Copy link

I have added 'configurable_attributes'

$productData = array(
'categories' => array(17),
'websites' => array(1),
'name' => 'Configurable product',
'description' => 'Description of configurable product',
'short_description' => 'Short Desciption',
'status' => 1,
'visibility' => 4,
'tax_class_id' => 1,
'price' => '1,40',
'associated_skus' => array('SKU-001', 'SKU-002'),
'configurable_attributes' => array(92), // attribute id
'price_changes' => array(
array(
'key' => 'color',
'value' => array(
array(
'key' => 92,
'value' => 'Red',
),
),
),
),
'additional_attributes' => array(
'single_data' => array(
array(
'key' => 'color',
'value' => 'Red', // Id or label of color, attribute that will be used to configure product
),
),
)
);

$result = $client->catalogProductCreate($session,'configurable',$attributeSet->set_id, 'SKU-003',$productData);

Try to debug the issue but cant happen please help me !

Thanks

@Chandu9012
Copy link

Hello hadl

'configurable_attributes' => array(158), // attribute id for sta_size
'price_changes' => array(
array(
'key' => 'sta_size',
'value' => array(
array(
'key' => 42, // 5 cm
'value' => '0',
),
array(
'key' => 43, // 7 cm
'value' => '0',
),
array(
'key' => 45, // 9 cm
'value' => '1,80',
),
),
),
),

In your above code 'configurable_attributes' id is 158 so let me know the 'key' => 42, // 5 cm and 'key' => 43, // 7 cm and 'key' => 45, // 9 cm you have used key those id are what is or for this is 'configurable_attributes' values id?

Thanks

@Chandu9012
Copy link

Hello @hadl,
Can you please provide me your Soap Call which is you used to Assign simple product to configurable product.
Thanks

@hadl
Copy link
Author

hadl commented Aug 25, 2015

@Chandu9012 This #4 (comment) is/was the working example.

Like i wrote in a previous comment, we switched to the simple configurable product extension (https://github.com/obigroup/magento-configurable-simple) and don't need the price changes anymore.

@Chandu9012
Copy link

Hello @hadl,
Now my Code is working fine. Thanks a lot.

Thanks,
Chandu Mer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants