...
use Protechstudio\PrestashopWebService\PrestashopWebService;
class FooController extends Controller
{
private $prestashop;
public function __construct(PrestashopWebService $prestashop)
{
$this->prestashop = $prestashop;
}
public function bar()
{
$opt['resource'] = 'customers';
$xml=$this->prestashop->get($opt);
}
}
...
use Prestashop;
...
public function bar()
{
$opt['resource'] = 'customers';
$xml=Prestashop::get($opt);
}
$xmlSchema=Prestashop::getSchema('categories'); //returns a SimpleXMLElement instance with the desired schema
$data=[
'name'=>'Clothes',
'link_rewrite'=>'clothes',
'active'=>true
];
$postXml=Prestashop::fillSchema($xmlSchema,$data);
//The xml is now ready for being sent back to the web service to create a new category
$response=Prestashop::add(['resource'=>'categories','postXml'=>$postXml->asXml()]);
$putXml=Prestashop::fillSchema($xmlSchema,$data,false,['manufacturer_name','quantity']);
//manufacturer_name and quantity only will be removed from the XML
/*
xml node with one language child example
...
<name>
<language id="1"/>
</name>
...
*/
$data= ['name'=>'Clothes'];
/*
xml node with n language children example
...
<name>
<language id="1"/>
<language id="2"/>
</name>
...
*/
$data= [
'name'=>[
1 => 'Clothes',
2 => 'Abbigliamento'
]
];