Draq Posted February 4, 2013 Share Posted February 4, 2013 Hello there, I have small problem and your help could save me. On the advice of one nice member of comunity i have this sript for changing order status: <?php require_once '../classes/Order.php'; require_once '../classes/OrderHistory.php'; require_once '../classes/ObjectModel.php'; $objOrder = new Order(1); //order with id=1 $history = new OrderHistory(); $history->id_order = (int)$objOrder->id; $history->changeIdOrderState(3, (int)($objOrder->id)); //order status=3 echo 'done'; ?> This script is placed in folderon root (ex. domain.com/folder/script.php) and its used on PS 1.4.3 (on PS 1.5.0.17 it writes same error). When i run this script it shows me: Fatal error: Class 'ObjectModel' not found in C:\wamp\www\143\classes\Order.php on line 29 Thank you very much for your help, in result i want to change order status with php script. Link to comment Share on other sites More sharing options...
vekia Posted February 5, 2013 Share Posted February 5, 2013 do the files in require_once: require_once '../classes/Order.php'; require_once '../classes/OrderHistory.php'; require_once '../classes/ObjectModel.php' exist there? Link to comment Share on other sites More sharing options...
Draq Posted February 5, 2013 Author Share Posted February 5, 2013 Yeah, they exist and path in script are also all right, because if not, it wrotes me different error. Is there something more what i must wrote to require_once, or anything like this? Thanks for help Link to comment Share on other sites More sharing options...
PascalVG Posted February 5, 2013 Share Posted February 5, 2013 (edited) Can it be that it complaints that it doesn't know class ObjectModel yet when loading order.php?. Try to move require_once '../classes/ObjectModel.php'; up BEFORE require_once '../classes/Order.php'; require_once '../classes/OrderHistory.php'; To FIRST load the ObjectModel class (i.e. make it known), THEN load order.php etc. Hope this helps, pascal (P.S. in 1.5.x, Order.php and OrderHistory.php are not in the folder /classes anymore, but in /classes/order/ SUB-folder) Edited February 5, 2013 by PascalVG (see edit history) 1 Link to comment Share on other sites More sharing options...
afranco Posted February 5, 2013 Share Posted February 5, 2013 Call objectmodel first! require_once '../classes/ObjectModel.php' require_once '../classes/Order.php'; require_once '../classes/OrderHistory.php'; Link to comment Share on other sites More sharing options...
Draq Posted February 5, 2013 Author Share Posted February 5, 2013 Many thanks for help, but not better... I know that in PS 1.5. it must be different, i have there: require_once '../classes/ObjectModel.php'; require_once '../classes/order/Order.php'; require_once '../classes/order/OrderHistory.php'; But result is not better. I don´t know, could it be something like in order.php is "class OrderCore extends ObjectModel" and in ObjectModel.php is "abstract class ObjectModelCore" I am only guesing, I am new in object in php. I want to upload script here on forum, but i don´t know how. Thanks for advice Link to comment Share on other sites More sharing options...
PresaExpert Posted February 6, 2013 Share Posted February 6, 2013 Hi, First can you please tell me where in the prestashop installation your script is placed? Second normally we dont need to include the specific classes in our scripts in Prestashop. We just include two files config/config.inc.php and init.php After that when you create an object of a class, it is loaded automatically. In your script remove all included classes, and include only the two files mentioned above, and then try. Hope it helps. Thanks Link to comment Share on other sites More sharing options...
Draq Posted February 7, 2013 Author Share Posted February 7, 2013 Sorry for late reply... As PresaExpert said, I did. So now my script look like here: <?php require_once '../init.php'; require_once '../config/config.inc.php'; $objOrder = new Order(1); //order with id=1 $history = new OrderHistory(); $history->id_order = (int)$objOrder->id; $history->changeIdOrderState(3, (int)($objOrder->id)); //order status=3 echo 'done'; ?> Maybye it works, but i have another erro Fatal error: Class 'Context' not found in C:\wamp\www\init.php on line 32 I have PS 1.5.0.17 placed on my locallhost server which creates me Wamp server. The scrript is placed in folder expcp, that means that i have it in C:\wamp\www\expcp\pokus.php (pokus.php is my script) Thank you very much for help, if this will be solved, i will be very happy Link to comment Share on other sites More sharing options...
Draq Posted February 10, 2013 Author Share Posted February 10, 2013 Can anybody help? Thank you! Link to comment Share on other sites More sharing options...
softhightech Posted March 14, 2017 Share Posted March 14, 2017 call the config file then it will work check my answer here : https://www.prestashop.com/forums/topic/309082-fatal-error-class-context-not-found/ 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