xxMAGRAOxx Posted December 30, 2015 Share Posted December 30, 2015 (edited) I can't believe in prestashop dont have ANY documentation about this. In all another cms i found VERY VERY EASY way and docs for how to insert product by script. I have search around the web and people say "read the source you have access all classes" ARE YOU KIDDING ME? he class Product, adminController has 10000 line of code and i'm trying to see what happen when i put the save button on the admin but its IMPOSSIBLE to track becouse have MANY internal mechanism that impossiblity to understand. tell me if i'm wrong becouse i'm very angry with this. Edited December 30, 2015 by xxMAGRAOxx (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted January 2, 2016 Share Posted January 2, 2016 It's not that complicated. Just include the main fies in your php script include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../init.php'); Then $product = new Product(); // add a few things here, check the product class to see which fields are required, like name etcThen$product->add(); That's all 1 Link to comment Share on other sites More sharing options...
xxMAGRAOxx Posted January 8, 2016 Author Share Posted January 8, 2016 You are right, but my insertion is not simple as that. Nemo1, i see you are a very experience in prestashop. Can you help me in another thing? I cannot unserstand how the product insert the tags. I find another solution. I'm insert the tags of product by the Tag object, but i need to insert by Product object. Can you tell in what function(s) this happen? I'm not able to track the insert process. Link to comment Share on other sites More sharing options...
NemoPS Posted January 9, 2016 Share Posted January 9, 2016 I believe it just manually adds tags $result = Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'product_tag` (`id_product`, `id_tag`, `id_lang`) VALUES '.implode(',', $sql_values) );That's what it does with the webservice method 1 Link to comment Share on other sites More sharing options...
xxMAGRAOxx Posted January 11, 2016 Author Share Posted January 11, 2016 (edited) I think is not a good way and i will continue using the Tag Object. $tag->setProducts(array(...) Is not the ideal(In my case), but better than insert manually. But, thanks for the help reply Nemo1. See you Edited January 11, 2016 by xxMAGRAOxx (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted January 13, 2016 Share Posted January 13, 2016 Consider instantiating an object for each tag might be resource consuming. Using a custom query is not a bad way, it's the only one if you care about performance 1 Link to comment Share on other sites More sharing options...
xxMAGRAOxx Posted January 14, 2016 Author Share Posted January 14, 2016 Yes, you touch in one important point that i pass in a moment. I am avoid to insert anything manually, becouse its more chance of errors, more work and research in code of prestashop, but i think at this time haven't another way. Not in tag becouse tag i instanciate one or other, the problem is in the custom features. Listen, i'm import 50-200 ebooks by xml and the ebooks has custom fields like isbn, author, edition, etc etc. Imagine foreach ebook i create custom feature for each feature. Ex: $idFeatureValue = $product->addFeaturesToDB($idFeatureIDISBN, null, 1);$product->addFeaturesCustomToDB($idFeatureValue, 1, 'isbn123'); $idFeatureValue = $product->addFeaturesToDB($idFeatureIDIdiom, null, 1);$product->addFeaturesCustomToDB($idFeatureValue, 1, 'Brazil'); $idFeatureValue = $product->addFeaturesToDB($idFeatureIDCollectionTitle, null, 1);$product->addFeaturesCustomToDB($idFeatureValue, 1, 'Star Wars'); ... many other custom features ... Can you see? Its very very very poor performance. Can you suggest something for me? ps: I need that field can be editable in adm. Link to comment Share on other sites More sharing options...
NemoPS Posted January 15, 2016 Share Posted January 15, 2016 The only way around I see is creating custom queries which have better performance 1 Link to comment Share on other sites More sharing options...
xxMAGRAOxx Posted January 15, 2016 Author Share Posted January 15, 2016 Allright. Thanks man. 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