У меня есть небольшая проблема с Prestashop WebService. Может ли помочь ypu? Я хотел бы получить все категории и подкатегории своего магазина с помощью API prestashop. Я следовал инструкциям и читал документацию, но я смущен об использовании «children()» и «attributes()».Получить все категории и подкатегории с помощью api prestashop
Это мой код:
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_error', 1);
define('DEBUG', false); // Debug mode
define('PS_SHOP_PATH', 'http://localhost/myshop'); // Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', '*********************************'); // Auth key (Get it in your Back Office)
require_once('api/PSWebServiceLibrary.php');
// Here we make the WebService Call
try
{
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
// Here we set the option array for the Webservice : we want customers resources
$opt['resource'] = 'categories';
// We set an id if we want to retrieve infos from a customer
if (isset($_GET['id']))
$opt['id'] = (int)$_GET['id']; // cast string => int for security measures
// Call
$xml = $webService->get($opt);
// Here we get the elements from children of customer markup which is children of prestashop root markup
$resources = $xml->children()->children();
}
catch (PrestaShopWebserviceException $e)
{
// Here we are dealing with errors
$trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) echo 'Bad ID';
else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';
else echo 'Other error';
}
?>
, а затем? Как я могу получить имя и идентификатор категории? И как я могу получить имя, идентификатор и таксономия подкатегорий?
Заранее спасибо.
? Дисплей = полный делает трюк – Petkovsky