maganapro Posted February 12, 2019 Share Posted February 12, 2019 Hello, I have a webservice that dump all the categories and products and then the service add the new data from a JSON file.... I'm used to work with Symfony and I handle thousands and thousand of entries in less that 30 seconds (+/-900,000 entries)... now in prestashop i'm using the classes Product` and `Category``and adding your 100 cats and 2000 products is taking more that 200 seconds.... It seems that in the core of prestashop there must be a `sleep()` between each `add` Searching on the code i found more that 150 sleep calls (sleep\(([0-9]+))... Can anybody point me on why this so slow on prestashop and how can i fix this ? Link to comment Share on other sites More sharing options...
Kogkalidis Posted February 13, 2019 Share Posted February 13, 2019 This has been coded this way probably to discourage brute force attacks. You could say why not ip blocking, or token check etc. I really don't know. In any case, as long as you want it to function another way, why not just to make an override where you will delete the sleep functions? Link to comment Share on other sites More sharing options...
maganapro Posted February 14, 2019 Author Share Posted February 14, 2019 Well the slowest part of the code was `$product->delete()`... I gain 150 seconds removing this block: $sql = "SELECT `id_product` FROM `"._DB_PREFIX_."product`"; $res = Db::getInstance()->executeS($sql); if ($res) { foreach ($res as $row) { $p = new Product($row['id_product']); $p->delete(); } } As you can see I'm deleting all the products... so instead of using the object `Product` i'm doing plain sql with `truncate` on all the necessary tables. I'm still using the Product object to add the products so the script runs in 50 seconds.... Still too slow Link to comment Share on other sites More sharing options...
maganapro Posted February 14, 2019 Author Share Posted February 14, 2019 Is anyway I can force the id_product on the method `new Product($pim_id)... I think that if i update the data instead of creating again and again the data data`will be faster.... First execution will create the data if product returns false... but if it resturns true it will update the data if($product = new Product($pim_id)){ $product->updata(); }else{ $product->add(); } 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