Fatal Error when activating Algolia WooCommerce

Hi,

I’m getting error when activating the Algolia WooCommerce plugin.
Installed plugins:

+--------------------------------------------+----------+--------+---------+
| name                                       | status   | update | version |
+--------------------------------------------+----------+--------+---------+
| akismet                                    | inactive | none   | 3.2     |
| algoliasearch-woocommerce                  | active   | none   | 0.4.0   |
| hello                                      | inactive | none   | 1.6     |
| search-by-algolia-instant-relevant-results | active   | none   | 1.6.0   |
| woocommerce                                | active   | none   | 2.6.9   |
| wordpress-importer                         | active   | none   | 0.6.3   |
+--------------------------------------------+----------+--------+---------+

Error Log:

2016/12/22 16:06:10 [error] 1086#0: *514 FastCGI sent in stderr: "PHP message: PHP Warning:  Invalid argument supplied for foreach() in /home/rw/html/wc/wp-content/plugins/search-by-algolia-instant-relevant-results/includes/class-algolia-plugin.php on line 352
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /home/rw/html/wc/wp-admin/plugins.php:0
PHP message: PHP   2. require_once() /home/rw/html/wc/wp-admin/plugins.php:422
PHP message: PHP   3. do_action() /home/rw/html/wc/wp-admin/admin-header.php:255
PHP message: PHP   4. WP_Hook->do_action() /home/rw/html/wc/wp-includes/plugin.php:453
PHP message: PHP   5. WP_Hook->apply_filters() /home/rw/html/wc/wp-includes/class-wp-hook.php:323
PHP message: PHP   6. aw_admin_notices() /home/rw/html/wc/wp-includes/class-wp-hook.php:298
PHP message: PHP   7. Algolia_Plugin->get_index() /home/rw/html/wc/wp-content/plugins/algoliasearch-woocommerce/includes/admin/admin.php:114
PHP message: PHP Fatal error:  Uncaught Error: Call to a member function is_enabled() on null in /home/rw/html/wc/wp-content/plugins/algoliasearch-woocommerce/includes/admin/admin.php:116
Stack trace:
#0 /home/rw/html/wc/wp-includes/class-wp-hook.php(298): aw_admin_notices('')
#1 /home/rw/html/wc/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(false, Array)
#2 /home/rw/html/wc/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#3 /home/rw/html/wc/wp-admin/admin-header.php(255): do_action('admin_notices')
#4 /home/rw/html/wc/wp-admin/plugins.php(422): require_once('/home/rw/html/w...')
#5 {main}
  thrown in /home/rw/html/wc/wp-content/plugins/algoliasearch-woocommerce/includes/admin/admin.php on line 116" while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /wc/wp-admin/plugins.php?activate=true&plugin_status=all&paged=1&s= HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "localhost", referrer: "http://localhost/wc/wp-admin/plugins.php"
2016/12/22 16:06:10 [error] 1086#0: *514 open() "/home/rw/html/50x.html" failed (2: No such file or directory), client: 127.0.0.1, server: _, request: "GET /wc/wp-admin/plugins.php?activate=true&plugin_status=all&paged=1&s= HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock", host: "localhost", referrer: "http://localhost/wc/wp-admin/plugins.php"

I have not index any posts with the plugin yet!

Edited

After deactivating the algoliasearch-woocommerce plugin, I have indexed my posts/products and activated the plugin again, no error afterwards.

I guess it requires indexed posts_product instance

1 Like

Hi @rahilwazir,

Thanks a lot for reporting this, it definitely looks like a bug.

I will fix this ASAP!

Thanks for your support,

1 Like

UDPATE: indexing fixed

Hello guys, I have the same issue with my shop, how can I index products(posts) in woocommerce?

Thanks,
Filip

1 Like

Hi @znamenak,

Do you have access to the beta of the new Algolia plugin for WooCommerce?

Hy @rayrutjes,
I have the WC plugin, but I think I have a problem with changing the search from my, to powered by your plugin, bcs I have some custom code on site… (www.xlpatronen.de)

I already tried and setup everything but it didnt work for me…
Even now is all “setup” and I see no change in searching or results…

Any advice?
Thanks
Filip

Hi @znamenak,

I can see that you have indeed enabled the search correctly and it should better display on this page: https://www.xlpatronen.de/?s=&post_type=product

Let me first suggest to change the Zoning CSS selector on Algolia Search -> WooCommerce -> Zoning and use main > .container instead. This will ensure the search replaces the whole container which is what the plugin is intended for.

Then you probably have something going wrong with the indexing. Could you try hitting the re-index everything button on the Algolia Search -> Indexing screen? Then please let me know if the tasks processes properly or if you have errors on the logs page or in the PHP logs.

Looking forward to get you up and running.

Hi @rayrutjes,
I have done these:
-zoning changed -> https://www.xlpatronen.de/?s=&post_type=product
-re-indexed, but dont know if the task was processed properly
https://www.dropbox.com/s/czpau0k1i9nt08z/Screenshot%202017-01-03%2010.26.05.png?dl=0
-in php logs is no errors
-search still not working :-/

I can make wp-admin account for you, if you could help me this way?
Thanks a lot!
Filip

The logs show that indexing gets stuck after trying to send the first batch of product records to Algolia.
Can I ask you to enable the PHP logs like explained here: https://community.algolia.com/wordpress/logs.html#php-logs

And then try to re-index and copy paste the errors you get in the wp-content/debug.log here?

An admin account won’t help me for now given I can’t access your PHP errors from the admin panel.

Hi,
I did all the php-logs setup in wp-config, but nothing popped-up in the debug.log file.
Please find FTP and wp-admin access in you support@ mailbox.

I would really like to use algolia search as soon as possible, It will be massive improvement for me and my customers.

F

OK so I investigated your admin, and given you have an extension for displaying the errors in the admin dashboard I could find the error: PHP Fatal error: Call to undefined method WC_Product_Simple::get_type() in /home/filipz26/public_html/wp-content/plugins/algoliasearch-woocommerce/includes/indexing.php on line 28

I will investigate this immediately and keep you posted.

After having tested the plugin with WooCommerce in version 2.5.5 I can tell that it works.
In the version of WooCommerce you sent over though, it seems that the WC_Product class is missing some code.

Did you make some changes manually to that code? Do you mind upgrading your version of WooCommerce or at least re-install a clean copy of WooCommerce 2.5.5: https://wordpress.org/plugins/woocommerce/developers/

Keep me posted,

I think my version of the WC 2.5.5. includes some custom code… I need to check this with my developers, will let you know about the progress.

If you can send me any specifics about the missing code, please do :slight_smile:

F

I just diffed the original file and yours and there are a lot of changes.

In the end, I think you should just re-add the get_type method present here: https://github.com/woocommerce/woocommerce/blob/2.5.5/includes/abstracts/abstract-wc-product.php#L348

Let me know if that is enough to solve your issue.

Hi @rayrutjes, we fixed the WC and now the search is re-indexed and working.
But how can I make some final setup/customization?
Bcs I have tested some possible search queries from customers and the result wasnt good…
For detailed info, pls check here:

Thanks for any advice, because in this setup, the search is not useful or better than the standard one, that I already have.

@rahilwazir I’ve been unable to re-produce the fatal error you reported at the beginning. Do you manage to still re-produce it?

@znamenak thanks for taking the time to detail your issue.
In the future, please do open a new topic on the forum so that it it easier to read the thread :wink:

Let me explain the current results you get.

Prefix matching & typo tolerance
When typing “2078FH” you actually have results like the ones containing “M2078FH”.
Please note that by Algolia does prefix matching, meaning that it tries to find any word starting with “2078FH”.
In the case of the “M2078FH”, the “typo tolerance” kicks in to return you the result. If you would turn off typo tolerance, the result wouldn’t appear.

Understanding the no results
When typing 2078 FH though, the engines tries to fetch words starting with “FH”. By default only the last word is used for prefix matching.
The engine also knows how to reconstitute splitted words, i.e. if you were to type “M 2078 FH” you would get the expected results.
Our split / concatenation algorithm that re-constructs words does not allow typos. Otherwise relevance would be hard to control. So the query “2078 FH” would only return results containing words starting with “FH” or containing exactly “2078FH”.

One workaround would consist of storing the references splitted into multiple chunks like “M 2078 FH”.

I suppose then it all comes down to how your users will want to search for references. Are you aware of them omitting the leading “M”?

I hope the little explanation helps understanding the results.

Hey @rayrutjes sorry for late reply.

Nope, it’s working fine now with latest version you guys sent to us (0.7.0).

Plugin lists

+--------------------------------------------+--------+--------+---------+
| name                                       | status | update | version |
+--------------------------------------------+--------+--------+---------+
| algoliasearch-woocommerce                  | active | none   | 0.7.0   |
| search-by-algolia-instant-relevant-results | active | none   | 1.7.0   |
| woocommerce                                | active | none   | 2.6.13  |
+--------------------------------------------+--------+--------+---------+