dr7tbien Posted April 26, 2012 Share Posted April 26, 2012 Today Iǜe been in Barcelona prestashop meeting and I was asking them them about how to insert categories and products using the object PRESTASHOP model, The staff there told me that admin folder autoload atomatically PRESTASHOP classes. I coud see how they a similar code in a blanka file $cats = getCategories); print_r ($cats); and I could watch the results of print_r showing a array with all categories. Now I've tryed the same code in my server in a blank file the the following result: Call to undefined function getcategories() in xxxx on line 365 Also I've tryed with: $cats = Category::getCategories); print_r ($cats); etc... My target is to load all the categories to check some issues, but by the moment is impossible as you can see. dr7tbien from Madrid 1 Link to comment Share on other sites More sharing options...
dr7tbien Posted April 27, 2012 Author Share Posted April 27, 2012 Hi. I could get the Solution for this. PRESTASHOP has a file named autoload.php in config/autoload.php The solution is load this file using foir example require_once. this is an example code: We can suppose our script is in /home/user/public_html/prestashop/admin_prestashop/myScript.php and now the myScript.php code <? include_once "../config/autoload.php"; /* getCategories arguments * arg 1 - id of the default language * arg 2 - true | false - Only active categories * arg 3 - true | false - Para indicar que no es un pedido * * Without arguments the result array is confused [/font] [font=courier new,courier,monospace]*/ $cats = Category::getCategories( (int)($cookie->id_lang), true, false ) ; print_r($cats); foreach ($cats as $cat) echo "\n id_category = " .$cats['id_category'] . " name = " . $category['name']; ?> 2 Link to comment Share on other sites More sharing options...
Nishanthan94 Posted August 29, 2019 Share Posted August 29, 2019 On 4/27/2012 at 11:47 AM, dr7tbien said: Hi. I could get the Solution for this. PRESTASHOP has a file named autoload.php in config/autoload.php The solution is load this file using foir example require_once. this is an example code: We can suppose our script is in /home/user/public_html/prestashop/admin_prestashop/myScript.php and now the myScript.php code <? include_once "../config/autoload.php"; /* getCategories arguments * arg 1 - id of the default language * arg 2 - true | false - Only active categories * arg 3 - true | false - Para indicar que no es un pedido * * Without arguments the result array is confused [/font] [font=courier new,courier,monospace]*/ $cats = Category::getCategories( (int)($cookie->id_lang), true, false ) ; print_r($cats); foreach ($cats as $cat) echo "\n id_category = " .$cats['id_category'] . " name = " . $category['name']; ?> its worked sir..thanks !!! 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