ruan567 Posted November 27, 2013 Share Posted November 27, 2013 (edited) Hi guys/girls I'm new to Prestashop development and this forum, and just wanted to say Hi and find out if someone has already done this (searched the forum but didn't find anything). I am building a module for Prestashop 1.5.6.1 that advises the user on which product to choose. Basically, after a question/answer sequence - I get back a line item (or multiples) containing the product reference, and the quantity of this product that one would need in order to accomplish a certain goal. This runs off external data but we are going to ensure that the products that are recommended are always available in the shop. The question/answer sequence runs fine in the front office and I have the output inside a javascript object. I now want to add the matching product from the prestashop database to the cart, by passing the cart the reference number of the product, the shop id and the quantity. I can't use the product ID in the prestashop database since it isn't linked to the external database except through the reference. Is there perhaps a function to automatically do it? If not any ideas where I should start? Hope I made myself clear Ruan Edited November 27, 2013 by ruan567 (see edit history) Link to comment Share on other sites More sharing options...
sumit mohanty Posted March 17, 2016 Share Posted March 17, 2016 How to insert data programmatically in database ? Please help asap. Link to comment Share on other sites More sharing options...
digitalDot Posted April 29, 2019 Share Posted April 29, 2019 (edited) I recomended , you use WebService and API for prestashop, you can try $id_cart = (int)$this->context->cookie->id_cart; $id_customer = (int)(isset($this->context->customer))? $this->context->customer->id : 0; $cart=new Cart($id_cart); $addressDeliveryID = $cart->id_address_delivery; $shopID = (int)Context::getContext()->shop->id; $rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS("select * from ato_product where reference ='".$reference."'"); if (isset ($rq[0]['id_product'])){ $productAttributeID = Product::getDefaultAttribute($rq[0]['id_product']); $success &= $cart->updateQty( (int)$row[1], (int)$rq[0]['id_product'], (int)$product['id_product_attribute'], null, 'up', (int)$id_address_delivery, new Shop((int)$cart->id_shop), false ); If have any problem you cant ask me in http://digitaldot.es/soporte-prestashop Regards Edited April 29, 2019 by digitalDot (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