Jump to content

Forcer l'id_product lors de la creation de l'objet


Recommended Posts

Bonjour,

Je souhaite mettre un ID spécifique pour chaque fiche produit crée...  logiquement ca devrait marcher:

 $product = new Product();
 $product->id_product = 40; // CA NE MARCHE PAS
 $product->active = 1;
 $product->name = array((int)Configuration::get('PS_LANG_DEFAULT') =>  $product_name);
 $product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') =>  $product_link);
 ...
  $product->add();

bien sur 40 est un exemple qui change a chaque fois que la fonction est appellée

 

Avez vous des idées ?

 

merci

 

cordialement

Edited by Alex-Kodd (see edit history)

Share this post


Link to post
Share on other sites

du coup je fais la brute en créeant une function...

$id_product = $product->id;
$id_user = $customer->id;
$change_id = Customer::changeProductId($id_user,$id_product);
public static function changeProductId($id_user,$id_product)
{ 
    $query = "UPDATE `"._DB_PREFIX_."product` SET id_product = '".$id_user."' WHERE id_product='" . $id_product . "'";
    $query= Db::getInstance()->Execute($query);
    $query2 = "UPDATE `"._DB_PREFIX_."product_lang` SET id_product = '".$id_user."' WHERE id_product='" . $id_product . "'";
    $query2= Db::getInstance()->Execute($query2);
    $query3 = "UPDATE `"._DB_PREFIX_."product_shop` SET id_product = '".$id_user."' WHERE id_product='" . $id_product . "'";
    $query3= Db::getInstance()->Execute($query3);
}

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More