Jump to content

Class 'Product' not found


hno2005

Recommended Posts

hi

I'm using prestashop 1.6 , I'm writing a webservice using php and I'm using prestashop webservice library (https://github.com/PrestaShop/PrestaShop-webservice-lib) . this is my code :

define('DEBUG', true);
define('PS_SHOP_PATH', 'http://xxxxx.com/');
define('PS_WS_AUTH_KEY', 'xxxxx');
require_once ('PSWebServiceLibrary.php');

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$xml = $webService->get(array('url' => PS_SHOP_PATH .'/api/customers?schema=synopsis'));

$customer = array();
$product = array();

/*if (strlen($_POST('c_email'))>0)
    $customer['email'] = Tools::getValue('c_email');
else
    $customer['email'] = '[email protected]';
*/
$customer['email'] ="[email protected]";
$customer['firstname'] = "navid";
$customer['lastname'] ="abutorab";
$customer['address1'] = "adres";
$customer['city'] = "citye";
$customer['phone'] = "09360544841";

$id['country'] = '165';
$id['lang'] = '1';
$id['currency'] = '1';
$id['carrier'] = '3';

$product['quantity'] ="1";
$id_product="10104";
$product['id'] = $id_product;
echo Product::getPriceStatic($product['id']) . "-----";
$product['price'] = Product::getPriceStatic($product['id']);
$product['name'] = Product::getProductName($product['id']);

$product['total'] = $product['price'] * $product['quantity'];

$xml->customer->firstname = $customer['firstname'];
$xml->customer->lastname = $customer['lastname'];
$xml->customer->email = $customer['email'];
$xml->customer->newsletter = '1';
$xml->customer->optin = '1';
$xml->customer->active = '1';


$opt = array('resource' => 'customers');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);



// ID of created customer
$id['customer'] = $xml->customer->id;

 

When I run the page , I get this error 

Class 'Product' not found in /home/xxxxx/public_html/test/test.php on line 37

line 37 is this:

$product['price'] = Product::getPriceStatic($product['id']);

what should I include to make it works fine ?

Link to comment
Share on other sites

  • 3 months later...

Product class is not included to the library.

attach to this file init.php only then you will be able to use Product class.

 

 

Hello,
 
My site has a similar error.
 
Fatal error: Class "category" not found classes/controller/Controller.php on line 134,
 
I have the Classes / Category.php file
My version of prestashop is 1.6.1.10
 
Any idea?
thanks
Link to comment
Share on other sites

 

Hello,
 
My site has a similar error.
 
Fatal error: Class "category" not found classes/controller/Controller.php on line 134,
 
I have the Classes / Category.php file
My version of prestashop is 1.6.1.10
 
Any idea?
thanks

 

 

Check category file, maybe it's empty

Link to comment
Share on other sites

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...