txabs Posted August 5, 2022 Share Posted August 5, 2022 Hello, i'm trying to make a very simple script, to update product prices via PHP.<?php include(dirname(__FILE__) . '/config/config.inc.php'); $cod_articulo = 'B39821'; $mysqli = mysqli_connect($localhost, $user, $pass, $database) or die(mysql_error()); function getIdByReference($reference) { if (empty($reference)) { return 0; } if (!Validate::isReference($reference)) { return 0; } $query = new DbQuery(); $query->select('p.id_product'); $query->from('product', 'p'); $query->where('p.reference = \'' . pSQL($reference) . '\''); return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query); } $id_articulo = getIdByReference($cod_articulo); echo($id_articulo.'<br/>'); //check new Product($product); $product->price = '10'; echo($product->price.'<br/>'); $product->update(); // line 48 echo ('Producto con ref: '.$reference.' actualizado a '.$product->price.' euros'); ?> It returns this errorPHP message: PHP Fatal error: Uncaught Error: Call to undefined method stdClass::update() in [***/testprecio.php:48 Stack trace:\n#0 {main}\n thrown in [***/testprecio.php on line 48' PS version 1.7.5.2 Do you know what i'm missing?? Thanks!! have a nice day Link to comment Share on other sites More sharing options...
ps8modules Posted August 8, 2022 Share Posted August 8, 2022 $product = new Product($id_product); $product->price = '10'; $product->update(); 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