Out of memory while generating csv feed
-
When I try to generate the csv feed I get a 500 error, reading in error logs file i see an “out of memory” error.
It is caused by the query in methodget_all_product_posts()in class-shareasale-wc-tracker-datafeed.php file, because the query reads all products in one shot and put all of them in memory … If we have many products, we can get the error above.To fix, I changed this method as follow, in file class-shareasale-wc-tracker-datafeed.php:
– I renamed the method
get_all_product_posts()inget_all_product_posts_ids()– in row 182, in get_posts(…) query, I added the attribute:
'fields' => 'ids'to get only post ids.– in
export()method (in the same class file, row 38) I changed first rows as follow:public function export( $file ) { $product_posts_ids = $this->get_all_product_posts_ids(); $rows = array(); foreach ( $product_posts_ids as $product_post_id ) { $product_post = get_post($product_post_id,’OBJECT’);This edits works fine for me and now I can create csv feed without errors.
I hope to be usefull for other developers 🙂
The topic ‘Out of memory while generating csv feed’ is closed to new replies.