Solved

Magento Api, cannot assign websites_id

Posted on 2013-11-14
5
525 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now