Skip to content
Advertisement

Uncaught Error: Call to a member function get_attributes() on null

Imports several thousand thumbnail images into existing products. For this purpose, I used the attribute that each product “featured-images” has, in which there is a link to the product.

JavaScript

The code works fine and sets the thumbnails, but when I log into the admin system I get an error:

Uncaught Error: Call to a member function get_attributes() on null.

what’s going on? What am I doing wrong?

Advertisement

Answer

I can’t see a call to get_attributes() in your code, which is what your error is referring to, however, if that is a typo then the error is referring to the use of $product->get_attribute(...) – in this instance your $product is apparently null. You could account for null values by doing something like the following:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement