sweszler Posted April 22, 2015 Share Posted April 22, 2015 (edited) First, sorry for my english. One part of my module that I create is importing manufacturers for existing products. I use: Db::getInstance()->insert('manufacturer', array( 'name' => $producent, 'date_add' => date("Y-m-d H:i:s"), 'active' => 1 )); $id_manufacturer = $this->get_id_manu_by_name($producent); Db::getInstance()->insert('manufacturer_lang', array( 'id_manufacturer' => $id_manufacturer, 'id_lang' => 1, )); Db::getInstance()->insert('manufacturer_shop', array( 'id_manufacturer' => $id_manufacturer, 'id_shop' => 1, )); and after that I update the product table: Db::getInstance()->update('product', array( 'id_manufacturer' => intval($id_manufacturer), ), 'id_product = "' . (int) $id_product . '"'); I have right id_manufacturer in product table. When i edit product in back office, manufacturer is set, but in front office I can't see this product on my manufacturer page. This works properly only after save again product in back office. How can I fix it? Edited April 22, 2015 by sweszler (see edit history) Link to comment Share on other sites More sharing options...
sandipchandela Posted April 22, 2015 Share Posted April 22, 2015 What you want do exactly? 1) Want to create manufacturers 2) Want to associate/assign manufacturers with products. ? which PS Version u r using? Link to comment Share on other sites More sharing options...
sweszler Posted April 22, 2015 Author Share Posted April 22, 2015 Thanks for response. I want to associate/assign manufacturers with product exactly. I'm using PS 1.5.6.2. Link to comment Share on other sites More sharing options...
sandipchandela Posted April 22, 2015 Share Posted April 22, 2015 $id_product=10; //product id will be 10 $id_manufacturer=5; //manufacturer id will be 5 Db::getInstance()->update('product', array( 'id_manufacturer' => intval($id_manufacturer), ), 'id_product = "' . (int) $id_product . '"'); Fire this query. 1 Link to comment Share on other sites More sharing options...
sweszler Posted April 22, 2015 Author Share Posted April 22, 2015 OK, I got it, successfully updated. I have in database in my product table id_manufacturer = 5. What next must be updated to display this product on manufacturer page in front office ? Link to comment Share on other sites More sharing options...
tuk66 Posted April 22, 2015 Share Posted April 22, 2015 You should use object approach instead of database one. Try: $product = new Product($id_product); $product->id_manufacturer = (int)$id_manufacturer; $product->save(); 1 Link to comment Share on other sites More sharing options...
sweszler Posted April 22, 2015 Author Share Posted April 22, 2015 (edited) Great, It works! Thank you tuk66. Edited April 22, 2015 by sweszler (see edit history) 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