Author Topic: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2  (Read 3392 times)

valekichia

  • Beginner
  • *
  • Posts: 28
Hello everybody.

I'm experiencing some issues after updating VM to version 3.2.2 (J version 3.7.0).

My VM category tree looks like this:

[root]
- main category 1
-- sub category 1
-- sub category 2
-- sub category 3
--- sub sub category 3a
--- sub sub category 3b
--- sub sub category 3c
- main category 2 ...
- main category 3 ...

I get error "Call to a member function displayMediaThumb() on null" on some product details pages and the layout gets broken.

It happens on products which are assigned to sub sub categories, when accessing the product details page from a category which isn't the deepest one.

For example, if I have a product in sub sub category 3a (also assigned to sub category 3 and main category 1), the product details page will be ok only accessing it through sub sub category 3a category view. Otherwise I get the error, that is from other categories or from VM homepage.

It that can be of any help, I set "Show products of subcategories" on yes in VM config.

I assign some products to all the levels of the nested categories because, despite this configuration, they won't be displayed in each category level.

If I assign the products only to the deepest subcategory the error won't show, but I loose the feature above...

Any ideas? ...may be I'm missing something... Can anybody help?

Thank you

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26747
  • Always on vacation
    • Jenkin Hill Internet
Using a commercial template?  Test with Protostar to check if a template issue.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM3.2.14.9808 on Joomla 3.8.6 PHP 7.0.29

Testing VM3.2.14.9808 on J3.8.6

valekichia

  • Beginner
  • *
  • Posts: 28
Hi jenkinhill, thank you for your reply!

I'm using a custom template, based on Helix framework (I don't know if I can mention it here, if not sorry, delete the info).

I tried Protostar and no problems occurred.

So now I know is a template issue.

I know that this makes it harder (if not impossible) for you to tell where the problem comes from, but may be I'm lucky and you can at least point me in the right direction and tell me where to "look" to solve it...

Thank you again

Typhoon365

  • Beginner
  • *
  • Posts: 33
  • VirtueMart Version: 3.2.2
We are also experiencing the same issue after updating to VM 3.2.2.

As a temporary work-around, we found if we tick the "Display Subcategories in product detail" in Virtuemart Configuration->Templates the error would go away and the product details would display properly. 

The side symptom of this workaround, is it will display any child categories at the bottom on the product page (ie. child categories of the category the product belongs to). 

We are also using a custom template and a few overrides. We found this config change worked for us for now until we can look at it further.

valekichia

  • Beginner
  • *
  • Posts: 28
Hello Typhoon365!

I tried your suggestion and I confirm that with the tick in "Display Subcategories in product details" the error goes away, with the downside that you noticed.

Since I'm also using some overrides, your suggestion let me think that maybe the issue was in the productdetails page override (ie. mytemplate/html/com_virtuemart/productdetails/default.php).

So I checked the pre-update and the after-update file components/com_virtuemart/views/productdetails/tmpl/default.php to check if there were any differences between the two (aside from my overrides, of course).

I discovered that line 253 has changed!

Before:
Code: [Select]
if (VmConfig::get('showCategory', 1)) {
After:
Code: [Select]
if ($this->cat_productdetails)  {
Honestly I'm not so skilled to tell if everything arises from this...

But in the end I copied my overrides on the new default.php file and uploaded it again as an override, then unchecked the "Display Subcategories in product detail" option and everything works fine (or at least seems to, I'm testing) without having the child categories displayed at the bottom of the product page.

I hope this can be of any help for you too...

However, one thing I still don't understand is why the "Show products of subcategories" option only works for 1 level of depth. That is the products belonging only to a sub sub category are not displayed on main category page.
Any ideas anybody?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26747
  • Always on vacation
    • Jenkin Hill Internet
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM3.2.14.9808 on Joomla 3.8.6 PHP 7.0.29

Testing VM3.2.14.9808 on J3.8.6

valekichia

  • Beginner
  • *
  • Posts: 28
Hi jenkinhill!

I read the post at your link but I think it was about backend, am I right?

I'm speaking about frontend display instead...


jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26747
  • Always on vacation
    • Jenkin Hill Internet
I thought full_catname_tree affected BE & FE - but I have not needed to use it.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM3.2.14.9808 on Joomla 3.8.6 PHP 7.0.29

Testing VM3.2.14.9808 on J3.8.6

valekichia

  • Beginner
  • *
  • Posts: 28
Hi jenkinhill,

I tried the hidden configuration but I confirm it only affects BE!

Nothing changed in FE.

Do you have any ideas to achieve what I need? (products from 2nd level subcategores to be displayed in each level of the category tree?)

Geppux

  • Jr. Member
  • **
  • Posts: 173
Same happens to me, and clicking on  "Display Subcategories in product details" the error goes away...
I'll contact also the template company...

spiri

  • Beginner
  • *
  • Posts: 2
Ticking "Enable legacy layouts" in the same config page worked for me //still testing 

samuelmf

  • Beginner
  • *
  • Posts: 46
Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
« Reply #11 on: August 22, 2017, 19:31:22 pm »
For me, ticking the "Display Subcategories in product details" woked but, there is no way to hide the subcategories without lose the layout?

On my case i use helix 3
Joomla 1.5.20 / VirtueMart 1.1.5

oneyozfest182

  • Beginner
  • *
  • Posts: 33
  • A beginner
Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
« Reply #12 on: January 09, 2018, 15:41:14 pm »
Hello Typhoon365!

I tried your suggestion and I confirm that with the tick in "Display Subcategories in product details" the error goes away, with the downside that you noticed.

Since I'm also using some overrides, your suggestion let me think that maybe the issue was in the productdetails page override (ie. mytemplate/html/com_virtuemart/productdetails/default.php).

So I checked the pre-update and the after-update file components/com_virtuemart/views/productdetails/tmpl/default.php to check if there were any differences between the two (aside from my overrides, of course).

I discovered that line 253 has changed!

Before:
Code: [Select]
if (VmConfig::get('showCategory', 1)) {
After:
Code: [Select]
if ($this->cat_productdetails)  {
Honestly I'm not so skilled to tell if everything arises from this...

But in the end I copied my overrides on the new default.php file and uploaded it again as an override, then unchecked the "Display Subcategories in product detail" option and everything works fine (or at least seems to, I'm testing) without having the child categories displayed at the bottom of the product page.

I hope this can be of any help for you too...

Sorry to revive an old topic, but I just wanted to let anyone else know that may be experiencing this, (as it just started happening to me), I'm using the protostar template and still got plagued with this, but replacing just
Code: [Select]
if (VmConfig::get('showCategory', 1)) { with
Code: [Select]
if ($this->cat_productdetails)  { in my override file completely solved this, so that line of code was 100% the issue causing the problem.