Solved

Magento Api, cannot assign websites_id

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
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…

760 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

24 Experts available now in Live!

Get 1:1 Help Now