Jump to content

create category via webservice more languages


ahrboktrexon

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

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...