Solved

Magento Api, cannot assign websites_id

Posted on 2013-11-14
5
530 Views
Last Modified: 2016-03-02
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?
0
Comment
Question by:webdesigner_dk
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:coreybryant
ID: 39662525
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 \ .
0
 

Accepted Solution

by:
webdesigner_dk earned 0 total points
ID: 39692971
Found the solution. The website_ids code should be:

'website_ids' => '1','base',

Open in new window


The webite assignment works now.
0
 
LVL 29

Expert Comment

by:coreybryant
ID: 39694563
I might be helpful if you found where you fond it others will not run into the same issue,
0
 

Author Comment

by:webdesigner_dk
ID: 39694886
Found the solution through trial and error, by using the code given by: http://www.magentocommerce.com/api/soap/introduction.html
0
 

Author Closing Comment

by:webdesigner_dk
ID: 39704071
This solution solved my problem.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Every business owner understands the significance of online customer reviews and the impact it can have on sales and revenues. With technology advancing at such a rapid pace, getting online reviews has never been easier, especially when many regions…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question