Raullara Posted April 22, 2014 Share Posted April 22, 2014 (edited) Hi again and thanks in advance. I'm trying to write an xml file with information of my shop's products from my custom module. I was trying a simple code to write an xml, but is not working. After that i tried to do it on the index.php in my local folder and it works. maybe my local prestashop has no permissions to write? i did the chmod 777 to the whole folder here's the code.... $xml = new DOMDocument("1.0"); $root = $xml->createElement("data"); $xml->appendChild($root); $id = $xml->createElement("id"); $idText = $xml->createTextNode('1'); $id->appendChild($idText); $title = $xml->createElement("title"); $titleText = $xml->createTextNode('"PHP Undercover"'); $title->appendChild($titleText); $book = $xml->createElement("book"); $book->appendChild($id); $book->appendChild($title); $root->appendChild($book); $xml->formatOutput = true; $xml->save("mybooks.xml") or die("Error"); Edited April 22, 2014 by Raullara (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted April 22, 2014 Share Posted April 22, 2014 Does it work if you first create an (empty) file with the name mybooks.xml? Maybe you're not allowed to create files programmatically... Link to comment Share on other sites More sharing options...
Raullara Posted April 23, 2014 Author Share Posted April 23, 2014 (edited) Solved, the problem was the files are created in the admin folder, the path was set on root, next to the php file, but prestashop execute the module from there. so i set an absolute path. Edited April 23, 2014 by Raullara (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now