Jump to content

ObjectModel not found in orders error


Draq

Recommended Posts

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

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 by PascalVG (see edit history)
  • Like 1
Link to comment
Share on other sites

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

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

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 :D

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

  • 4 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...