?
Solved

Magento Api, cannot assign websites_id

Posted on 2013-11-14
5
Medium Priority
?
547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

771 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