Jump to content
ahrboktrexon

create category via webservice more languages

Recommended Posts

Hi guys, I'm trying to submit to Prestashop web services a request for creating a category under an existing category.

I tried a lot, but I cannot get it working, always "This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request." message is returned.

This is my code, can you help?


				$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
				$xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/categories?schema=synopsis'));
				$resources = $xml->children()->children();
				$resources->id_parent = 48; #existing category in destination sho
				$resources->active = 1;
				$resources->is_root_category = 0;
				$resources->active = 1;

				foreach($ar_languages as $key => $remote_language) {
					$resources->name->language[$key][0] = 'category name';
					$resources->name->language[$key][0]['id'] = $remote_language->id;

					$resources->description->language[$key][0] = 'category description';
					$resources->description->language[$key][0]['id'] = $remote_language->id;

					$resources->link_rewrite->language[$key][0] = 'link rewrite';
					$resources->link_rewrite->language[$key][0]['id'] = $remote_language->id;

					$resources->meta_title->language[$key][0] = 'meta title';
					$resources->meta_title->language[$key][0]['id'] = $remote_language->id;

					$resources->meta_keywords->language[$key][0] = 'meta keywords';
					$resources->meta_keywords->language[$key][0]['id'] = $remote_language->id;

					$resources->meta_description->language[$key][0] = 'meta description';
					$resources->meta_description->language[$key][0]['id'] = $remote_language->id;
				}

				$return_xml = $webService->add(
					array(
						'resource' => 'categories',
						'postXml' => $xml->asXML()
					)
				);

$ar_languages is an array containing all languages of the remote prestashop.

 

Can you help?

 

Thank you

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More