Link to home
Start Free TrialLog in
Avatar of webdesigner_dk
webdesigner_dk

asked on

Magento Api, cannot assign websites_id

Hi,

I am trying to create a product through the Magento Api with soap2" og "ws-1 compliance".

I am using this code:
<?php
    ini_set('display_errors', 1);

    try {
            $proxy = new SoapClient('http://webhost/api/v2_soap?wsdl', array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));
            $sessionId = $proxy->login((object)array('username' => 'user', 'apiKey' => 'key'));

            $result = $proxy->catalogProductCreate((object)array('sessionId' => $sessionId->result, 'type' => 'simple', 'set' => '4', 'sku' => 'sku-'.time(),
            'productData' => ((object)array(
                'name' => 'Product name',
                'website_ids' => 'base',
                'description' => 'Product description',
                'short_description' => 'Product short description',
                'weight' => '10',
                'status' => '1',
                'visibility' => '4',
                'price' => '100',
                'tax_class_id' => 2
            ))));
            
            var_dump($result->result);
   
        } catch (SoapFault $e) {
            print_r($proxy);
        }
?>

Open in new window


Everything works fine, except that there is no website assigned to the product.

I have tried both with website code and id. The product is created, but no website assigned.

The website get's assigned when I try using "Soap", but I have to make this work with "Soap 2" with ws-1 compliance mode.

Any thoughts?
Avatar of coreybryant
coreybryant
Flag of United States of America image

I am not a big fan of shops like these because it is more difficult to customize them.

Have you checked out Extending Magento web services API v2.

Looking at that it says:
http://yourmagentoinstallation/api/v2_soap/?wsdl=1

Open in new window

and it looks like you have
http://webhost/api/v2_soap?wsdl

Open in new window

(I think you might be missing the \ .
ASKER CERTIFIED SOLUTION
Avatar of webdesigner_dk
webdesigner_dk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I might be helpful if you found where you fond it others will not run into the same issue,
Avatar of webdesigner_dk
webdesigner_dk

ASKER

Found the solution through trial and error, by using the code given by: http://www.magentocommerce.com/api/soap/introduction.html
This solution solved my problem.