Jump to content

[HELP] Update active field for products with WebAPI


Daviex

Recommended Posts

Hello everyone.


So, I need to update the field of "active" into a product that was already created as non active, but

using the WebServices won't work.

 

First, I tried to extract the original XML of the product, change the field and send it back with a PUT Request, but

it won't accept some field to change ( They wasn't change at all ).

Second, I created a blank XML of Product, changed active and the ID, but it goes to request me for all data that are not optional, but was like rewriting from 0 the XML.

 

There is something that I'm missing?

 

This is my second attempt code:

                               $opt = array('resource' => 'products?schema=blank');
                                $xml_active_empty = $webService->get($opt);

                                $resources_active = $xml_active_empty->children()->children();

                                $resources_active->id = $product_id;
                                $resources_active->active = '1';

                                $opt = array('resource' => 'products');
                                $opt['putXml'] = $xml_active_empty->asXML();
                                $opt['id'] = $product_id;
                                $result = $webService->edit($opt); 

Can someone help me? I tried to look into docs, but nothing came out.

 

Thanks for the help

Link to comment
Share on other sites

 

Hello everyone.

So, I need to update the field of "active" into a product that was already created as non active, but

using the WebServices won't work.

 

First, I tried to extract the original XML of the product, change the field and send it back with a PUT Request, but

it won't accept some field to change ( They wasn't change at all ).

Second, I created a blank XML of Product, changed active and the ID, but it goes to request me for all data that are not optional, but was like rewriting from 0 the XML.

 

There is something that I'm missing?

 

This is my second attempt code:

                               $opt = array('resource' => 'products?schema=blank');
                                $xml_active_empty = $webService->get($opt);

                                $resources_active = $xml_active_empty->children()->children();

                                $resources_active->id = $product_id;
                                $resources_active->active = '1';

                                $opt = array('resource' => 'products');
                                $opt['putXml'] = $xml_active_empty->asXML();
                                $opt['id'] = $product_id;
                                $result = $webService->edit($opt); 

Can someone help me? I tried to look into docs, but nothing came out.

 

Thanks for the help

 

 

JYI, I did a "manual" edit over the db at last by activating it over "*_product" and "*_product_shop", but I would like to know anyway what I was doing wrong with the put command.

 

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...